Another simple SQL problem

johnuk4

Active member
Joined
Feb 18, 2006
Messages
25
Programming Experience
Beginner
Hi, im trying to get a value from a combo box to work in an sql string. Just wondering if anyone could tell me what is wrong with the following sqlstring in the 'cboPrinterMake' area:

SQLStr2 = "SELECT Hardware.Hardware_Model, Hardware.Hardware_Make FROM Hardware WHERE (((Hardware.Hardware_Make)= cboPrinterMake));"

Much appreciated

john


 
*sigh* I see this a lot, so it must be a common misconseption, but SQL Server (or what ever Database you are using) knows nothing about your form. Therefor it cannot know anything about cboPrinterMake. As a result... it's not going to pull in the value from it and run it in the query.

VB.NET:
SQLStr2 = "SELECT Hardware.Hardware_Model, Hardware.Hardware_Make FROM Hardware WHERE (((Hardware.Hardware_Make)= '" & cboPrinterMake.Text & "'));"

-tg
 
Back
Top