中间层组件将执行应用程序中的数据访问例程。该组件将调用多个SQL Server存储过程来执行数据库更新。所有这些过程调用都在单个事务的控制下运行。中间层的代码将实现以下对象:
SqlCommand comm = connection.CreateCommand();
SqlTransaction trans;如何将代码添加到组件以指定针对此类错误的最高保护级别(两个用户尝试同时更新相同的数据)。
发布于 2010-03-31 17:02:16
您使用IsolationLevel
using (SqlConnection con = new SqlConnection(connectionString))
{
using (SqlTransaction tran = con.BeginTransaction(IsolationLevel.Serializable))
{
SqlCommand cmd = con.CreateCommand();
// etc...
con.Open();
}
}您仍然需要捕获适当的SQL异常...
https://stackoverflow.com/questions/2551502
复制相似问题