OleDb adapter returns empty results

  • Thread starter Thread starter Guest
  • Start date Start date
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;
}
 
Try Like '%something%' instead. The * is an Access-ism.


---

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

***************************
Think Outside the Box!
***************************
 
Thanks a lot, the wild card '%' worked. Its strange though, the * works in
access but it doesnt using inline queries.
 
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
 
Back
Top