Currently i am facing a problem. I had a form containing two text boxes and in these two textboxes user fill up the date.
and as per user's date i have to search in the data from the database in between these two dates. i passed these two values as value1 and value2 through querystring in other page where i have to show the search results
I am using ms-access as backend and visual studio 2005 and language used is c#.
i had used following code
Expand|Select|Wrap|Line Numbers
- string selectstr = "select cl.cId,cl.cName,od.orderId,od.orderDate,od.specifiedAmount,od.paidAmount from ClientDetails cl,OrderDetails od where cl.cId=od.cId and od.orderDate between @orderDate1 and @orderDate2 order by od.orderId desc";
- try
- {
- OleDbCommand cmd=new OleDbCommand(selectstr,conn);
- conn.Open();
- DateTime tmpdate1 = DateTime.Parse(Request.QueryString["value1"]);
- DateTime tmpdate2 = DateTime.Parse(Request.QueryString["value2"]);
- cmd.Parameters.Add("@orderDate1",OleDbType.DBDate).Value = tmpdate1;
- cmd.Parameters.Add("@orderDate2", OleDbType.DBDate).Value = tmpdate2;
- OleDbDataAdapter ada = new OleDbDataAdapter(cmd);
- DataSet ds = new DataSet();
- ada.Fill(ds);
- ddlSearch.DataSource = ds;
- ddlSearch.DataBind();
- }
- catch (Exception ex)
- {
- Response.Write(ex.Message);
- }
- conn.Close();
i got the following error:
String was not recognized as a valid DateTime.
Please give me suggestion that how can i debug this error.
thanks in advance for your suggestions