Reputation: 137
I have to take 2 values from DateTimePicker and then compare their values with that in database.
Code:
string dt_start = dateTimePicker1.Value.ToShortDateString();
string dt_end = dateTimePicker2.Value.ToShortDateString();
string mySelectQuery = "Select * from " + out_table + " WHERE [Date] Between " + dt_start + " and " + dt_end + " ";
It is not showing any error, but I am not getting output values.
Upvotes: 3
Views: 4930
Reputation: 2205
Access uses # for dates. This should work:
string mySelectQuery = "Select * from " + out_table + " WHERE [Date] Between #" + dt_start + "# and #" + dt_end + "#";
Upvotes: 3
Reputation: 8333
try the following select statement:
string mySelectQuery = "Select * from " + out_table + " WHERE [Date] Between '" + dt_start + "' and '" + dt_end + "' ";
Upvotes: 0