How to stop/cancel query from cancel button of asp.net web form
I have one web form having 2 button show and cancel.In show button click event I am showing cancel button and executing query,If query take long time.I want to cancel that query from cancel button.I searched lot, sqlcommand.cancel() method may need to use.How to use that because in button1 writing like thisButton1_click()
{
String connectionString = WebConfigurationManager.ConnectionStrings["smitaConnectionString"].ConnectionString;
String sqlselect = "select PName from Item";
SqlConnection con = new SqlConnection(connectionString);
try
{
con.Open();
SqlCommand cmd = new SqlCommand(sqlselect, con);
DataSet ds = new DataSet();
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(ds);
GridView1.DataSource = ds;
GridView1.DataBind();
}
catch (Exception ex)
{
ex.ToString();
}
finally
{
con.Close();
}
}