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
Printable View
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
Just use normal string interpolation...VB Code:
SELECT * FROM table WHERE table.somefield = " & myVariable or textbox.text & " ORDER BY suchandsuch;"
I'll try it out.
Many thanks ;)
hmm...I tried this:
and I got this error: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 & ")"
"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.
hmm...try putting a msgbox before the sql statement to see what it is actually doing, like this. It may be something really obvious that usually makes itself known using msgboxes.VB Code:
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 & ")"
Worked! Thanks :D