Paramaterised access queries
-
I'm trying to build a form to search an access membership database in c# I want to be able to search by firstname and lastname to start with but sometimes i might not be able to remember how to spell the whole name so I want names that start with what I've typed in.
OleDbCommand command = _databaseConnection.CreateCommand(); command.CommandText = "SELECT * FROM MEMBERS WHERE fname like '?*' AND lname like '?*'"; command.Parameters.Add(new OleDbParameter("fname",firstName)); command.Parameters.Add(new OleDbParameter("lname", lastName));
I seem to have tried every combination of ?* ?% '?*' etc. in the sql statement, does anyone know what the correct syntax is to do this? Cheers Russ -
I'm trying to build a form to search an access membership database in c# I want to be able to search by firstname and lastname to start with but sometimes i might not be able to remember how to spell the whole name so I want names that start with what I've typed in.
OleDbCommand command = _databaseConnection.CreateCommand(); command.CommandText = "SELECT * FROM MEMBERS WHERE fname like '?*' AND lname like '?*'"; command.Parameters.Add(new OleDbParameter("fname",firstName)); command.Parameters.Add(new OleDbParameter("lname", lastName));
I seem to have tried every combination of ?* ?% '?*' etc. in the sql statement, does anyone know what the correct syntax is to do this? Cheers Russ