Problem with ADODB.Recordset using LIKE operator.

  • Thread starter Alberto Uttranadhie
  • Start date
A

Alberto Uttranadhie

Hi, everybody,

I have a 'strange' problem with a ADO recordset. Here are
my code lines:

Function MyFunction()
On Error GoTo Err_MyFunction
Dim rst As New ADODB.Recordset
Dim str As String
str = "SELECT * FROM tblMyTable WHERE MyField
LIKE '*Whatever*';"
rst.Open str, CurrentProject.Connection, adOpenKeyset,
adLockOptimistic
MsgBox rst.RecordCount
rst.Close
Exit_MyFunction:
Exit Function
Err_MyFunction:
MsgBox Err.Description
Resume Exit_MyFunction
End Function

When using LIKE operator --with or without asterisks--
rst.RecordCount is always zero. I have tried such string
in a query and it works perfectly, but when it runs as
shown only zero returns. On the other side, when using
numeric values and 'equal to' symbol ( = ) or '>' '<' it
works fine.

Am I doing something wrong?

As always, thanks in advance,

Alberto Uttranadhie (Spain)
 

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