//create a class in the name of
DButility file with some methods which are u want like bellow
public class DbUtility
{
public DbUtility()
{
}
public static SqlConnection OpenConnection()
{
SqlConnection cnn = new SqlConnection(ConfigurationManager.ConnectionStrings["YouConnectionString"].ConnectionString);
if (cnn.State == ConnectionState.Open)
{
cnn.Close();
cnn.Open();
}
else
{
cnn.Open();
}
return cnn;
}
// then create a method for delete your record like follow
public static int DeleteRecord(string query)
{
int i = 0;
SqlCommand com = new SqlCommand();
com = new SqlCommand(query, DbUtility.OpenConnection());
i = com.ExecuteNonQuery();
DbUtility.CloseConnection();
return i;
}
// now if u want to delete your re the just write the bellow code for delete button click
protected void button_Delete_Click(object sender, EventArgs e)
{
string qry = "delete * from table_xyz";
DbUtility.DeleteRecord(qry);
}
}
// just u need to write only query in cs page...