存储过程 update需不需要回滚
程序原来是直接用SQL语句update数据表中的值。
执行SQL的update,需要一个回滚机制
SqlTransaction tran = con.BeginTransaction();
com.Transaction = tran;
try
{
iResult = com.ExecuteNonQuery();
tran.Commit();
}
catch (System.Exception ex)
{
this.Response.Write(ex.Message);
tran.Rollback();
}
finally
{
con.Close();
}
现在我改成存储过程了。
SqlCommand cmd = new SqlCommand("AAAAAA", con);
cmd.CommandType = CommandType.StoredProcedure;
SqlParameter sampParm = cmd.Parameters.Add("@AAAA", SqlDbType.Int);
sampParm.Value = 1;
还需要判断成功否,并回滚吗?