Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple Variables in One SQL select statement 1

Status
Not open for further replies.

lance59

IS-IT--Management
Mar 6, 2007
50
US
I have 2 variables in one select statement. I can put one in at a time and the select works, both in and I end up with no errors but a blank datagridview. Using SQL 2005 and VB.Net (Visual Studio 2008)

TextBox1.Text = str_item_column
TextBox2.Text = str_item_type

Dim SQL As String = "select * from item_table where '" + str_item_column +'" = '" + str_item_type + "'"

Any help is appreciated.

TIA
 
You don't need single quotes around the column name:
Code:
Dim SQL As String = "select * from item_table where " + str_item_column + " = '" + str_item_type + "'"
Hope this helps

HarleyQuinn
---------------------------------
Carter, hand me my thinking grenades!

You can hang outside in the sun all day tossing a ball around, or you can sit at your computer and do something that matters. - Eric Cartman

Get the most out of Tek-Tips, read FAQ222-2244: How to get the best answers before posting.

 
Glad I could help, thanks for the star [smile]

HarleyQuinn
---------------------------------
Carter, hand me my thinking grenades!

You can hang outside in the sun all day tossing a ball around, or you can sit at your computer and do something that matters. - Eric Cartman

Get the most out of Tek-Tips, read FAQ222-2244: How to get the best answers before posting.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top