By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,460 Members | 1,095 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,460 IT Pros & Developers. It's quick & easy.

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

P: n/a
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();

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


Dec 7 '05 #1
Share this Question
Share on Google+
2 Replies

P: n/a
try using % as your wildcard character. ADO uses a different one than

Dec 7 '05 #2

P: n/a
<pi********> wrote in message
try using % as your wildcard character. ADO uses a different one than

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??

Dec 7 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.