Good morning. I have a problem with my code. Does not understand the variables for a query between dates DateTimePicker
.
This is my code.
public DataTable selcfecharegitro()
{
DataTable dt = new DataTable();
OleDbDataAdapter da = new OleDbDataAdapter();
DataSet ds = new DataSet();
OleDbConnection cone = new OleDbConnection(cc.conaccess);
DateTime desde = Convert.ToDateTime(new datosform().dtpdesde);
DateTime hasta = Convert.ToDateTime(new datosform().dtphasta);
da.SelectCommand = new OleDbCommand("select * FROM Registro where Fecha_uso between = '" + desde + "' and '" + hasta + "' ", cone);
da.Fill(ds);
dt = ds.Tables[0];
return dt;
}
and it shows me this error at the time I look for the range of dates.
Additional information: Unable to cast object of type 'System.Windows.Forms.DateTimePicker' to type 'System.IConvertible'.