Accessing an ACCESS database back end.
DateTime searchDate = DateTime.Now.AddDays(0);
DateTime searchDate2 = DateTime.Now.AddDays(-170);
Using OleDbCommand cmd;
cmd = new OleDbCommand("SELECT * FROM tbl_Sample_Login_table WHERE LoginDate BETWEEN @nowDate AND @thenDate);
cmd.Parameters.Add("@nowDate", OleDbType.DBDate).Value = searchDate;
cmd.Parameters.Add("@thenDate", OleDbType.DBDate).Value = searchDate2;
dbConnection.Open();
dataAdapter.SelectCommand = cmd;
DataSet ds = new DataSet();
** The crazy thing is I keep getting results which only account for searchDate2 and ignores my now search date!? Watching the execution my now date shows today... but when the data set loads it uses some other date every time!
Can anyone tell me why only one of the "BETWEEN" dates is actually getting used in the SELECT query?
Thanks for all responses.
DateTime searchDate = DateTime.Now.AddDays(0);
DateTime searchDate2 = DateTime.Now.AddDays(-170);
Using OleDbCommand cmd;
cmd = new OleDbCommand("SELECT * FROM tbl_Sample_Login_table WHERE LoginDate BETWEEN @nowDate AND @thenDate);
cmd.Parameters.Add("@nowDate", OleDbType.DBDate).Value = searchDate;
cmd.Parameters.Add("@thenDate", OleDbType.DBDate).Value = searchDate2;
dbConnection.Open();
dataAdapter.SelectCommand = cmd;
DataSet ds = new DataSet();
** The crazy thing is I keep getting results which only account for searchDate2 and ignores my now search date!? Watching the execution my now date shows today... but when the data set loads it uses some other date every time!
Can anyone tell me why only one of the "BETWEEN" dates is actually getting used in the SELECT query?
Thanks for all responses.