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();
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