Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / General 1 / December 2005

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Electric Bliss - 07 Dec 2005 01:33 GMT
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
pietlinden@hotmail.com - 07 Dec 2005 01:59 GMT
try using % as your wildcard character. ADO uses a different one than
Access.
Electric Bliss - 07 Dec 2005 08:40 GMT
> 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
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.