Home All Groups Group Topic Archive Search About

OleDb adapter returns empty results

Author
9 Dec 2004 5:53 PM
Anon
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;
        }

Author
9 Dec 2004 7:16 PM
Cowboy (Gregory A. Beamer) - MVP
Try Like '%something%' instead. The * is an Access-ism.


---

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

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

Show quote
"Anon" wrote:

> 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;
>         }
>
Author
9 Dec 2004 7:18 PM
Anon
Thanks a lot, the wild card '%' worked. Its strange though, the * works in
access but it doesnt using inline queries.

Show quote
"Cowboy (Gregory A. Beamer) - MVP" wrote:

> Try Like '%something%' instead. The * is an Access-ism.
>
>
> ---
>
> Gregory A. Beamer
> MVP; MCP: +I, SE, SD, DBA
>
> ***************************
> Think Outside the Box!
> ***************************
>
> "Anon" wrote:
>
> > 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;
> >         }
> >
Author
9 Dec 2004 9:15 PM
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

AddThis Social Bookmark Button