I am trying to filter records using "Like" with asterisks, it works when Access 2010 returns a lot of records. I do not understand why it does not return anything when used with ADO. The code contains several tables and columns, so I made a simple query for troubleshooting. Here is the code:
strsql = "SELECT tproducts.Prod_Name FROM tproducts " _ & " WHERE tproducts.Prod_Name Like " & Chr(34) & "SO*" & Chr(34) Set cn = New ADODB.Connection cn = connString cn.Open Set rs = New ADODB.Recordset rs.Open strsql, cn, adOpenStatic, adLockOptimistic ' test here iRecCount = rs.RecordCount rs.MoveFirst
Recordcount returns -1.
When "Like" is replaced with "equals", it returns the correct record, so I'm sure that it can connect to the database, for example:
strsql = "SELECT tproducts.Prod_Name FROM tproducts " _ & " WHERE tproducts.Prod_Name = " & Chr(34) & "SONY Vaio SVD13213CXB" & Chr(34)
Is there a special way to use the Like operator in ADO?
What other methods can be filtered to give results in the same way as with "Like"? For example, to find all the products "SVD"?
source share