Code appears to behave differently than native SQL

G

Guest

I am attempting to retrieve a single row with a SELECT that contains a LIKE
clause.
I build the SELECT string in subroutine and open a record set via an EXECUTE
as in the following example:

Set rsPrimaryID = adoCon.Execute(sqlFindPrimaryID)

The SQL in the string looks like:

SELECT DMX_Entries.Description, DMX_Entries.EntryId ,
DMX_Entries.CollectionId FROM DMX_Entries WHERE ((DMX_Entries.Description)
LIKE 'AI - Primary*');

When this string is copied and pasted into a query that has a linked table
defined, it works. When this is executed in code, I get a record count of
zero. The open of the connection (ODBC) appears to be working. There are no
errors when the SQL is executed, and the record set object appears to be
created, its just empty. I have removed the where clause and get records
back. There is something about the where clause that appears to behave
differently in code than in native SQL.
Can anyone help me?
 
R

Rick Brandt

Crisp said:
I am attempting to retrieve a single row with a SELECT that contains
a LIKE clause.
I build the SELECT string in subroutine and open a record set via an
EXECUTE as in the following example:

Set rsPrimaryID = adoCon.Execute(sqlFindPrimaryID)

The SQL in the string looks like:

SELECT DMX_Entries.Description, DMX_Entries.EntryId ,
DMX_Entries.CollectionId FROM DMX_Entries WHERE
((DMX_Entries.Description) LIKE 'AI - Primary*');

When this string is copied and pasted into a query that has a linked
table defined, it works. When this is executed in code, I get a
record count of zero. The open of the connection (ODBC) appears to
be working. There are no errors when the SQL is executed, and the
record set object appears to be created, its just empty. I have
removed the where clause and get records back. There is something
about the where clause that appears to behave differently in code
than in native SQL.
Can anyone help me?

In ADO the wildcard character is % not *.
 

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