469,626 Members | 1,438 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,626 developers. It's quick & easy.

Query works in Access but not with exec call from .net

Greetings all...

This has been driving me nutz and I was hoping an expert could help shed
some light.

Why does this query work in Access but not in an
OleDbCommand.ExecuteReader() call?

SELECT tblFilterPhrases_Subject.strPhrase
FROM tblFilterPhrases_Subject
WHERE ((('VIAGRA') Like '*' & [strPhrase] & '*'));
Here is the C# code I'm using:

OleDbCommand sqlCommand;
sqlCommand = new System.Data.OleDb.OleDbCommand();

try
{
sqlCommand.Connection = conn;
sqlCommand.CommandText = "exec Query1";
dreader = sqlCommand.ExecuteReader();
}

The reader comes back as not null... but it contains zero records. In Access
I run the query and it comes back with the correct record. What am I missing
here?

EB

Dec 7 '05 #1
2 1306
try using % as your wildcard character. ADO uses a different one than
Access.

Dec 7 '05 #2
<pi********@hotmail.com> wrote in message
news:11*********************@g49g2000cwa.googlegro ups.com...
try using % as your wildcard character. ADO uses a different one than
Access.


Thanks Pietlinden. I found what the problem is but I don't know how to fix
it. Here is my sql statement again:

SELECT tblFilter_Subject.strPhrase
FROM tblFilter_Subject
WHERE ((('VALíUMM') Like '%' & [strPhrase] & '%'));
Some of the data in strPhrase has open square brackets in it! Took me for
bleedin' ever to find that... so the next question is... how to escape an
open bracket in the situation above??

EB
Dec 7 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

12 posts views Thread by John Scott | last post: by
6 posts views Thread by AJ | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.