I am writing code to search for books where some string is within the book's name
it works fine when i set the search parameter to the whole name of the book but when i use the % sign wildcard no results seem to generate
this is my code :
i know it's something in the sql query i just cant seem to figure it out.
it works fine when i set the search parameter to the whole name of the book but when i use the % sign wildcard no results seem to generate
this is my code :
Code:
OleDbConnection myConn = null;
string ConnString = @"Provider=Microsoft.Jet.OLEDB.4.0;User Id=;Password=;Data Source=Library.mdb";
myConn = new OleDbConnection(ConnString);
string OleDb = "SELECT Nom,Auteur,DateEdition FROM Livres WHERE Nom Like '%bookname%'";
OleDbCommand cmd = new OleDbCommand(OleDb,myConn );
cmd.Parameters.Add("@bookname", txtfind.Text);
dt = new DataTable();
OleDbDataAdapter ad = new OleDbDataAdapter(cmd);
ad.Fill(dt);
dgsearchbooks.DataSource = dt;
Comment