protected void btnSumbit_Click(object sender, EventArgs e)
{
//Begin Transaction
string conn = ConfigurationManager.AppSettings["YourConnectionString"];
SqlConnection objConnection = new SqlConnection(conn);
SqlTransaction trans = objConnection.BeginTransaction();
try
{
InsertData(ref trans, objConnection);
//Do Multiple Operations
trans.Commit();
}
catch
{
//Rollback Transaction
trans.Rollback();
}
}
private void InsertData(ref SqlTransaction trans, SqlConnection objConnection)
{
//Delete Product
SqlCommand cmd = new SqlCommand("Delete From Table Where ID=1", objConnection, trans);
cmd.ExecuteNonQuery();
}
//Put InsertData function in any Tier
www.learnlogic.blogspot.com