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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Like sql query

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Does anyone know how to do an sql query using the like keyword from a VB app?

Ex: sqlSel = "Select ""INVOICE"".""Debtor AC NO"" as acno, ""INVOICE"".""JOB NO"" AS JOB "
sqlSel = sqlSel & ", ""INVOICE"".""QUOTE NO"" AS QTE FROM ""INVOICE"" "
sqlSel = sqlSel & "WHERE ""INVOICE"".""QUOTE NO"" LIKE " & Trim(txtQuoteNum.Text) & "%"
 
When doing your LIKE, you need to embed the value inside single quotes (if it is a string value). So, your final line should be:

sqlSel = sqlSel & "WHERE ""INVOICE"".""QUOTE NO"" LIKE '" & Trim(txtQuoteNum.Text) & "%'"

If you are working with a numeric column, LIKE does not work.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top