for connecting a .mdb database from C#, how to pass a variable for selecting, e.g.:
for a string field called "a", if I directly pass a string to it, it is OK, e.g.
OleDbCommand cmd = new OleDbCommand(@"SELECT * FROM mytable where a= 'hello' " , con);
but now I want to pass a string variable str_var to it, how to do?
the following one is wrong,
OleDbCommand cmd = new OleDbCommand("SELECT * FROM mytable where a = " + str_var , con);
the following one is also not correct:
OleDbCommand cmd = new OleDbCommand("SELECT * FROM mytable where a = @str_var " , con);
what would be the correct one?
thanks!