OleDb adapter returns empty results

G

Guest

I dont know where I am going wrong but the OleDB dataadapter returns data
when it is a simple select statement like "Select * from Customers".

but when i try to do a simple search query like "SELECT * FROM Customers
WHERE LastName LIKE '*something*'", it does not return anything, even though
the same query returns records in the data base. Currently I am using MS
Access as the DB. The code for the function is as follows : (The code works
perfectly fine for the Select * from Customers query)


public System.Data.DataSet execQueryDS(string Query)
{
DataAccess DataObj = new DataAccess();
OleDbConnection Cxn = DataObj.getConnection();
OleDbDataAdapter daGeneric = new OleDbDataAdapter(Query,Cxn);
System.Data.DataTable dtGeneric = new System.Data.DataTable();
System.Data.DataSet dsGeneric = new System.Data.DataSet();
daGeneric.Fill(dtGeneric);
dsGeneric.Tables.Add(dtGeneric);
return dsGeneric;
}
 
G

Guest

Try Like '%something%' instead. The * is an Access-ism.


---

Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************
 
G

Guest

Thanks a lot, the wild card '%' worked. Its strange though, the * works in
access but it doesnt using inline queries.
 
C

cecil

Your example is missing what is probably the problem! The problem is
most likely in the string you send in to this method, especialy because
you stated it worked with one string but not another. Let's see the
code you use to build the string and call this method.
Cecil Howell MCSD, MCT
 

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