Select using LIKE in VB .NET

G

Guest

I am trying to create a select that uses the LIKE operator. If I leave off
the where clause I get all the data but when I add the where with a LIKE I
get nothing. If I paste it into access it runs fine. Am I missing something
in the way it is formatted? Here is what I am using.

strSQL = "SELECT CatalogID, tProductDescription, tDocument "
strSQL &= "FROM tblCatalog WHERE tProductDescription LIKE '*SONIX*'"

Try
oCmd = New OleDb.OleDbCommand
With oCmd
.Connection = _
New OleDb.OleDbConnection(strConn)
.Connection.Open()
.CommandText = strSQL
oDR = .ExecuteReader()
End With...
There are many rows with the word SONIX in them and like I said it works in
access but not when I call access from VB.

Thanks,

John
 
M

Mike Labosh

I am trying to create a select that uses the LIKE operator. If I leave off
the where clause I get all the data but when I add the where with a LIKE I
get nothing. If I paste it into access it runs fine. Am I missing
something
in the way it is formatted? Here is what I am using.

In Access, the Microsoft JET Engine processes your SQL using it's own
dialect:
strSQL = "SELECT CatalogID, tProductDescription, tDocument "
strSQL &= "FROM tblCatalog WHERE tProductDescription LIKE '*SONIX*'"

In VB.NET, the OLE-DB DataProvider processes the SQL using a subtly
different flavor that uses % instead of *:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top