Results 1 to 6 of 6

Thread: simple SQL question

  1. #1
    jasonjb
    Guest

    simple SQL question

    I need to pass info held in Long variables and a TextBox control array to a database in a SQL statement...can anyone give me some sample code on how to do it? (I already have DB connection established and stuff...just need the SQL)
    Thanks!
    -jason

  2. #2
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923
    Just use normal string interpolation...
    VB Code:
    1. SELECT * FROM table WHERE table.somefield = " & myVariable or textbox.text & " ORDER BY suchandsuch;"

  3. #3
    jasonjb
    Guest
    I'll try it out.
    Many thanks

  4. #4
    jasonjb
    Guest
    hmm...I tried this:
    Code:
    "INSERT INTO Members VALUES(" & NewID & ", " & Text1(0).Text & ", " & Text1(1).Text & ", " & Text1(2).Text & ", " & Text1(6).Text & ", " & SSN & ", " & Text1(7).Text & ", " & Text1(5).Text & ", " & Typevar & ", " & FFID & ")"
    and I got this error:
    "The name 'hj' is not permitted in this context. Only constants, expressions, or variables allowed here. Column names are not permitted."
    "hj" is what I typed into the first of the textboxes as a test.
    Any help is appreciated. thanks.

  5. #5
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923
    hmm...try putting a msgbox before the sql statement to see what it is actually doing, like this
    VB Code:
    1. Msgbox "INSERT INTO Members VALUES(" & NewID & ", " & Text1(0).Text & ", " & Text1(1).Text & ", " & Text1(2).Text & ", " & Text1(6).Text & ", " & SSN & ", " & Text1(7).Text & ", " & Text1(5).Text & ", " & Typevar & ", " & FFID & ")"
    . It may be something really obvious that usually makes itself known using msgboxes.

  6. #6
    jasonjb
    Guest
    Worked! Thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width