Please try putting a try{} catch(Exception ex) {} BLock around your SQL query.
like
try{
cmd.Connection = con;
cmd.Parameters.AddWithValue("@fromtime",drpstrattime.SelectedItem.Value );
cmd.Parameters.AddWithValue("@totime",drpend.SelectedItem.Value);
cmd.Parameters.AddWithValue("@description",txtdesc.Text);
cmd.ExecuteNonQuery();
con.Open();
cmd.ExecuteNonQuery();
Label1.Text = "succes..";
con.Close();
}
catch(Exception ex)
{
}
then you can find the error way easier.
2nd thing is that i guess your program fails while the first executeQuery().
You have to open the connection before executing!
Also you will get a long back if it worked, i guess a not 0 is it worked.
then you can set the label to sucess if it worked and to false if it failed.(do this in the catch Block)
Debug your code and see if it jumps into the catch block, then please hand us the exeptionmessage.
What are you supposed to do with this?
string constr = ConfigurationManager.ConnectionStrings["my"].ConnectionString;
using (SqlConnection con = new SqlConnection(constr))
{
using (SqlCommand cmd = new SqlCommand("INSERT INTO t2(fromtime,totime,description) VALUES(@fromtime,@totime,@description)"))
{
would you mind commenting that out and just do it without the "using"
like this :
string constr = ConfigurationManager.ConnectionStrings["my"].ConnectionString;
SqlConnection con = new SqlConnection(constr);
SqlCommand cmd = new SqlCommand("INSERT INTO t2(fromtime,totime,description) VALUES(@fromtime,@totime,@description)");
Just for a try.