Your SQL query has code in it that the database engine won't understand.
quote:Originally posted by asters
chmcmd = New OleDbCommand("SELECT * FROM IncomeManager WHERE Date >= StartDateTimePicker.Value AND Date <= EndDateTimePicker.Value", chmcon)
I'll make the assumption that "Date" in your query is the field you want to test. You are passing what appears to be .NET object code into the SQL query as literal text which will be interpreted as T-SQL syntax.
"StartDateTimePicker.Value" and "EndDateTimePicker.Value" won't be understand by the database engine.
Where are your parameters? I would expect to see something like "@StartDate" (for SQL server) or "?" (for OleDb) in the appropriate locations. Such as:
"SELECT * FROM IncomeManager WHERE Date >= ? AND Date <= ?"
or better still:
"SELECT * FROM IncomeManager WHERE Date BETWEEN ? AND ?" (unless your logic dictates otherwise)
But also as Shasur pointed out, you are using the same name for parameters. Instead, try this (adjust the actual syntax accordingly):
IncRep1OleDbDataAdapter.SelectCommand.Parameters.A dd("@StartDate", startDate)
IncRep1OleDbDataAdapter.SelectCommand.Parameters.A dd("@EndDate", endDate)
(Note that I think for the OleDb command, the actual name of the parameter doesn't link back into the database as it does in SqlClient.SqlCommand. However, use the name for clarification and possible later reference.)