P
Paul Gray via DotNetMonster.com
Hi
I am having touble determining the correct syntax for my SQL query using
the OleDbCommand parameters and the 'like' operator with the 'where' clause
.. I would like to use the wildcard % at either end of my parameter, but no
matter what I try, nothing seems to work, on the surface the query couldn't
be simpler and works perfectly with text outside of this context. Can
anyone please advise?
Note: txtFirstname.Text refers to the text entered into a textbox
void btn_click(Object sender , EventArgs e)
{
OleDbConnection conAuthors = new OleDbConnection(
"PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA Source=D:\\Mydatabase\\Code\\
Latest28092004\\pg.MDB" );
conAuthors.Open();
string OleString = "Select Code, Description, Retail from Pricelist0804
where Description like '%?%'";
OleDbCommand cmdSelectAuthors = new OleDbCommand( OleString, conAuthors );
cmdSelectAuthors.Parameters.Add ("?", txtFirstname.Text);
dgrdMenu.DataSource = cmdSelectAuthors.ExecuteReader();
dgrdMenu.DataBind();
conAuthors.Close();
I am having touble determining the correct syntax for my SQL query using
the OleDbCommand parameters and the 'like' operator with the 'where' clause
.. I would like to use the wildcard % at either end of my parameter, but no
matter what I try, nothing seems to work, on the surface the query couldn't
be simpler and works perfectly with text outside of this context. Can
anyone please advise?
Note: txtFirstname.Text refers to the text entered into a textbox
void btn_click(Object sender , EventArgs e)
{
OleDbConnection conAuthors = new OleDbConnection(
"PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA Source=D:\\Mydatabase\\Code\\
Latest28092004\\pg.MDB" );
conAuthors.Open();
string OleString = "Select Code, Description, Retail from Pricelist0804
where Description like '%?%'";
OleDbCommand cmdSelectAuthors = new OleDbCommand( OleString, conAuthors );
cmdSelectAuthors.Parameters.Add ("?", txtFirstname.Text);
dgrdMenu.DataSource = cmdSelectAuthors.ExecuteReader();
dgrdMenu.DataBind();
conAuthors.Close();