关于Transaction事务的未赋值问题
try{
conn.Open();
trans = conn.BeginTransaction();
cmd.Transaction = trans; //命令的Transaction属性初始化
int i=cmd.ExecuteNonQuery();
= "update [table] set accountamount=accountamount+100 where accountid='B'";
cmd.ExecuteNonQuery();
();
}
catch (SqlException ex)
{
trans.Rollback();//显示错误,trans未赋值,是什么原因啊???
throw ex;
}
finally
{
conn.Close();
}
[ 本帖最后由 niaomingjian 于 2012-2-1 15:13 编辑 ]