Hi,
I'm a newbie in C#, I wrote an OLEDb query with positioned parameter. It seems not working. Can anyone please point out where I've done wrong? Thanks in advance.
Here is my code:
using
{
String key = textbox1.text;
string cmd = "Select * from [" + filename + "] Where " + fieldname + " like ?";
OleDbCommand command= new OleDbCommand(cmd, conn);
OleDbParameter parameter = new OleDbParameter("@key",OleDbType.VarChar,30);
parameter.Value = "'%"+key+"%'";
command.Parameters.Add(parameter);
conn.Open();
OleDbDataAdapter dataAdapter = new OleDbDataAdapter(cmd, conn);
OleDbCommandBuilder commandBuilder = new OleDbCommandBuilder(dataAdapter);
DataTable
table.Locale = System.Globalization.
dataAdapter.Fill(table);
}