使用
Microsoft SQL Server 2008(SP1)
试图创建如下事务:

OleDbConnection con;
OleDbTransaction transaction = null;
...
transaction = con.BeginTransaction(IsolationLevel.Snapshot);

并获取错误:
System.Data.OleDb.OleDbException (0x8004D008): Neither the isolation level nor a strengthening of it is supported.
   at System.Data.OleDb.OleDbTransaction.ProcessResults(OleDbHResult hr)
   at System.Data.OleDb.OleDbTransaction.BeginInternal(ITransactionLocal

事务处理)
在system.data.oledb.oledbconnectioninternal.beginTransaction(隔离级别
隔离水平)
在system.data.oledb.oledbconnection.beginTransaction(隔离级别
隔离水平)
我确保在SQL Server Management Studio中运行以下命令:
ALTER DATABASE mydb SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
ALTER DATABASE mydb  SET ALLOW_SNAPSHOT_ISOLATION ON;
ALTER DATABASE mydb  SET READ_COMMITTED_SNAPSHOT ON;
ALTER DATABASE mydb  SET MULTI_USER;

我有什么遗漏吗?

最佳答案

用sqlclient替换oledb(如注释中建议的oded)。
或者,在开始事务之前执行此sql命令:

SET TRANSACTION ISOLATION LEVEL SNAPSHOT;

关于sql-server - 隔离级别或增强隔离级别均不受支持,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/9726958/

10-12 17:12