hai...Plz hep me...
I want to retrieve a row at a particular date from access database using c# code..
I was using the following code..An exception occured as DATA TYPE MISMATCH IN CRITERIA EXPRESSION..
OleDbDataAdapter ad = new OleDbDataAdapter("select * from schedule where listdate='"+dateTimePicker1.Value.ToShortDateString()+"'", con);
DataSet ds = new DataSet();
ad.Fill(ds, "schedule");
if (ds.Tables[0].Rows.Count > 0)
{
scheduleDataGridView.DataSource = ds;
scheduleDataGridView.DataMember = ds.Tables[0].ToString();
}
Please help me.............Thanks in Advance.....
Loading
Master BillaPosted Aug 13, 2009, 5:27 AM
if it correct , please mark it as answer.
Just break point on this line and get that query and put in your MS access database directly
OleDbDataAdapter ad = new OleDbDataAdapter("select * from schedule where listdate=#"+dateTimePicker1.Value.ToShortDateString()+"#", con);
2.Check data format is correct.
thank you
Mark Francis VillamorPosted Mar 4, 2018, 12:31 PM
Master BillaPosted Aug 13, 2009, 7:52 AM
weclome
Soumya SurendranPosted Aug 13, 2009, 6:24 AM
Soumya SurendranPosted Aug 13, 2009, 5:14 AM
Master BillaPosted Aug 13, 2009, 5:04 AM
Just small change in your code
OleDbDataAdapter ad = new OleDbDataAdapter("select * from schedule where listdate=#"+dateTimePicker1.Value.ToShortDateString()+"#", con);
Thank youDataSet ds = new DataSet();
ad.Fill(ds, "schedule");
if (ds.Tables[0].Rows.Count > 0)
{
scheduleDataGridView.DataSource = ds;
scheduleDataGridView.DataMember = ds.Tables[0].ToString();
}