Hello
I have developed search functionality between two dates which is working correctly on my local server but it gives error after deploying on server.
My code is :
protected void btnsubmit_Click(object sender, EventArgs e)
{
DateTime fromdate = DateTime.Parse(txtfromdate.Text);
DateTime todate = DateTime.Parse(txttodate.Text);
SqlCommand cmd = new SqlCommand("Select * from Expenses where Date between '" + fromdate + "' and '" + todate + "'", con);
con.Open();
DataSet ds = new DataSet();
SqlDataAdapter sda = new SqlDataAdapter(cmd);
sda.Fill(ds);
con.Close();
gvsearch.DataSource = ds;
gvsearch.DataBind();
}
gvsearch is gridview id, I am trying bind search results to gridview
after deploying it gives following error :
String was not recognized as a valid DateTime.
May be -
This code prone to error
DateTime fromdate = DateTime.Parse(txtfromdate.Text);
DateTime todate = DateTime.Parse(txttodate.Text);
What to do after deploying to overcome this error
Thanks