I form a sample request as follows.
OleDbCommand SelectCommand = new OleDbCommand( "SELECT * FROM Посещения WHERE Дата Between dt_begin = ? and dt_end = ?", connection); SelectCommand.Parameters.Add("dt_begin", OleDbType.Date).Value = new DateTime(2015, 6, 1); SelectCommand.Parameters.Add("dt_end", OleDbType.Date).Value = new DateTime(2015, 6, 31);
After executing the request, I get an error:
System.Data.OleDb.OleDbException (0x80040E10): missing value for one or more required parameters.
The first parameter gets the date 01.06.2015. The second is 06/30/2015. About formatting is not sure, but if it is wrong, there should have been an error related to the date format (exactly).
I check numbers for checking myself into variables. The name of the table Посещения
. Дата
- the name of the column. with them there can be no problems.
So what, in general, can we talk? As I understand, there are only two parameters.
OleDbCommand
support named parameters? - Donil