我有一个classic ASP
页面,想要将transaction isolation level
设置为READ UNCOMMITTED
。使用this documentation我提出了以下内容:
Set conn = GetConnection
conn.IsolationLevel = adXactReadUncommitted
'conn.BeginTrans
'conn.CommitTrans
Set cmd = Server.CreateObject("ADODB.Command")
Set cmd.ActiveConnection = conn
cmd.CommandType = adCmdText
cmd.CommandText = "INSERT INTO [dbo].[A] ([IsolationLevel]) SELECT CASE transaction_isolation_level WHEN 0 THEN 'Unspecified' WHEN 1 THEN 'ReadUncommitted' WHEN 2 THEN 'ReadCommitted' WHEN 3 THEN 'Repeatable' WHEN 4 THEN 'Serializable' WHEN 5 THEN 'Snapshot' END AS TRANSACTION_ISOLATION_LEVEL FROM sys.dm_exec_sessions where session_id = @@SPID"
Set rs = cmd.Execute()
response.write(conn.IsolationLevel)
最后一次response.write
正确地给了我256
(READ UNCOMMITTED
),但当我查询表格时,我只获得了ReadCommitted
条记录。
有谁能说出我做错了什么?
这是GetConnection
函数的主体:
FUNCTION GetConnection()
DIM strConnectionDotNet : strConnectionDotNet = "Data Source=..."
SET GetConnection = Server.CreateObject("adodb.connection")
GetConnection.connectionstring="Provider=sqloledb;" & strConnectionDotNet
GetConnection.open
END FUNCTION
答案 0 :(得分:2)
正如文件中所述:
注意:IsolationLevel设置在下次之前无法使用 调用BeginTrans。
这有点奇怪,但我需要以下内容:
conn.BeginTrans
... sql statement is executed here
conn.CommitTrans
甚至认为T-SQL
语句是SELECT
。此外,在conn.CommitTrans
之后它仍然使用默认隔离级别(在数据库上下文中指定的级别)。