If you're using question marks, it should be formatted more like:
cmd1.CommandText = "SELECT ID FROM Employee "
+ "WHERE id BETWEEN ? AND ?";
OleDbParameter p1 = new OleDbParameter();
OleDbParameter p2 = new OleDbParameter();
cmd1.Parameters.Add(p1);
cmd1.Parameters.Add(p2);
p1.Value = "01";
p2.Value = "03";
If you're using AddWithValue, it should be like:
Dim SqlString As String = "Select * From Contacts Where FirstName = ? And LastName = ?"
Using conn As New OleDbConnection(ConnString)
Using cmd As New OleDbCommand(SqlString, conn)
cmd.CommandType = CommandType.Text
cmd.Parameters.AddWithValue("FirstName", txtFirstName.Text)
cmd.Parameters.AddWithValue("LastName", txtLastName.Text)
If you want to use the @ symbol, then it's set up differently...
Dim SqlString As String = "Select * From Contacts Where FirstName = @FirstName And LastName = @LastName"
Using conn As New OleDbConnection(ConnString)
Using cmd As New OleDbCommand(SqlString, conn)
cmd.CommandType = CommandType.Text
cmd.Parameters.AddWithValue("FirstName", txtFirstName.Text)
cmd.Parameters.AddWithValue("LastName", txtLastName.Text)
Some of this is from:
Parameter Queries in ASP.NET with MS Access[
^]
and some is from:
Pass Parameter to OleDbCommand[
^]
Hopefully the others didn't confuse you, but you're mixing the styles around...as were they.