G
Guest
I have an Access database used to organize my images taken with my digital
camera. There are many tables representing dates and each contains image
names and descriptions of each image. I am rewriting my web site using C#
and I am trying to select only those images where the description contains
certain keywords. Using a query that contains the LIKE parameter from my
program returns no records. Using the same query directly in the Access
database and the correct records are returned. If I remove the LIKE
parameter in my program, then all records are returned. I have been trying
to resolve this issue for a week. Can anyone assist?
Following is the code including the query that works and the one that don't:
System.Data.OleDb.OleDbConnection conn = new
System.Data.OleDb.OleDbConnection();
conn.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data source=
h:\inetpub\wwwroot\database\gallery.mdb";
conn.Open();
string Query= "SELECT Images, Description FROM 040904 WHERE Description Like
\"*Lewis*\"";
// Query= "SELECT Images, Description FROM 040904";
OleDbCommand cmdSearch = new OleDbCommand(Query, conn);
cmdSearch.ExecuteNonQuery();
OleDbDataReader sreader = cmdSearch.ExecuteReader();
while (sreader.Read())
{
string d= sreader.GetString(0);
}
sreader.Close();
conn.Close();
camera. There are many tables representing dates and each contains image
names and descriptions of each image. I am rewriting my web site using C#
and I am trying to select only those images where the description contains
certain keywords. Using a query that contains the LIKE parameter from my
program returns no records. Using the same query directly in the Access
database and the correct records are returned. If I remove the LIKE
parameter in my program, then all records are returned. I have been trying
to resolve this issue for a week. Can anyone assist?
Following is the code including the query that works and the one that don't:
System.Data.OleDb.OleDbConnection conn = new
System.Data.OleDb.OleDbConnection();
conn.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data source=
h:\inetpub\wwwroot\database\gallery.mdb";
conn.Open();
string Query= "SELECT Images, Description FROM 040904 WHERE Description Like
\"*Lewis*\"";
// Query= "SELECT Images, Description FROM 040904";
OleDbCommand cmdSearch = new OleDbCommand(Query, conn);
cmdSearch.ExecuteNonQuery();
OleDbDataReader sreader = cmdSearch.ExecuteReader();
while (sreader.Read())
{
string d= sreader.GetString(0);
}
sreader.Close();
conn.Close();