• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 160
  • Last Modified:

Help on sql select statement

Hey, I'm using vb.net 2005.
I have this SELECT statement that goes like this

sql2 = "SELECT* from isimtable WHERE '" & CBSearchItem.Text & "' LIKE '" & cbItem.Text & "'"

this doesn't seem to do anything, if i put an actual column in place of cbsearchitem.text, then it works o.k., but if the value of cbsearchitem.text is the exact name of one of my columns, shouldn't i get the same results.  What's going on?
1 Solution
Guy Hengel [angelIII / a3]Billing EngineerCommented:
assuming that cbsearchitem is the name of the column to search, and cbItem the value, and the database is ms sql server:

sql2 = "SELECT * from isimtable WHERE [" & CBSearchItem.Text & "] LIKE '%" & cbItem.Text & "%'"

you might want to specify those details...
DustinHinkelAuthor Commented:
you were correct in your assumptions except the database is an access database.  using oledb.  You're code worked perfectly.  Thank you very much.  I will try to be more specific in the future.

Featured Post

[Webinar] Improve your customer journey

A positive customer journey is important in attracting and retaining business. To improve this experience, you can use Google Maps APIs to increase checkout conversions, boost user engagement, and optimize order fulfillment. Learn how in this webinar presented by Dito.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now