Avatar of yarlapati

asked on 

Casting DateTimePicker Value to query DataSet

Hi All,

I am trying to query a DataSet filled with data....

I have a DateTimePicker on a form and when user enters the value I need to query the database with that DateTimePicker.Value.

DataTable dt1 = ds1.Tables[0];

DataRow[] foundrows;

dateTimePicker1.Format = DateTimePickerFormat.Short;
string strDateTime = dateTimePicker1.Value.ToString();
// System.Convert.ToDateTime(dateTimePicker1.Value);

//perform filter of Dataset

foundrows = ds1.Tables[0].Select("DrawDate like '" + strDateTime +"'");

Now when I do the above I am getting the following error message.

I have DrawDate as smallDateTime in the database.

"Cannot perform 'like' operation on system.datetime and system.string".

Can someone please tell me where I am going wrong.


Avatar of undefined
Last Comment
Mohammed Nasman

8/22/2022 - Mon