|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
OleDb adapter returns empty resultswhen 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! *************************** 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; > } > 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; > > } > > |
|||||||||||||||||||||||