SqlConnection myconnection = new SqlConnection(SqlDapperHelper.connStrWrite);
myconnection.Open();
SqlTransaction myTrans = myconnection.BeginTransaction();
SqlCommand myCommand = new SqlCommand();
myCommand.Connection = myconnection;
myCommand.Transaction = myTrans;
myCommand.CommandText = "select * from Categories where categoryid=1";
myCommand.ExecuteNonQuery();
myTrans.Commit();
修改该数据行是有排他锁的 但是查询就没有 默认的共享锁吗?
我该怎么在c# 代码里在开启事务查询时强制给查询的数据加排他锁???
慕后森
相关分类