Saturday 10 December 2011

Transaction in SQL

SQL Transaction In C#                                                                                                        





SQL Transaction In C# means either run all command or do nothing (ROLLBACK)
to know the transaction process bit briefly lets take an example.

SqlTransaction trans;                       //globaly declared


try
{
cmd1=new sql(________);
int i=cmd.ExecuteNonQuery();



cmd2=new sql(________)
int j=cmd.ExecuteNonQuery()


trans.Commit();
if((i>0 ) && (j>0))
{
"record inserted"
}
catch(Exception)
{
trans.Rollback();
"Record not insered";
}
con.close();



No comments:

Post a Comment

Print Only Grid View in ASP.net

ASP.net How to Print Only GridView < div id ="gridviewDiv" >   < asp:GridView ID ="gridViewToPri...