如何使用经典 ASP 设置事务隔离级别?
How to set transaction isolation level using classic ASP?
我有一个 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
) 但是当我查询 table 我只得到 ReadCommitted
条记录。
谁能告诉我哪里做错了?
这里是 GetConnection
函数的主体:
FUNCTION GetConnection()
DIM strConnectionDotNet : strConnectionDotNet = "Data Source=..."
SET GetConnection = Server.CreateObject("adodb.connection")
GetConnection.connectionstring="Provider=sqloledb;" & strConnectionDotNet
GetConnection.open
END FUNCTION
正如文档中所说:
Note: The IsolationLevel settings will not work until next time
BeginTrans is called.
这有点奇怪,但我需要以下内容:
conn.BeginTrans
... sql statement is executed here
conn.CommitTrans
甚至认为 T-SQL
语句是 SELECT
。此外,在 conn.CommitTrans
之后它仍然使用默认隔离级别(在数据库上下文中指定的级别)。
我有一个 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
) 但是当我查询 table 我只得到 ReadCommitted
条记录。
谁能告诉我哪里做错了?
这里是 GetConnection
函数的主体:
FUNCTION GetConnection()
DIM strConnectionDotNet : strConnectionDotNet = "Data Source=..."
SET GetConnection = Server.CreateObject("adodb.connection")
GetConnection.connectionstring="Provider=sqloledb;" & strConnectionDotNet
GetConnection.open
END FUNCTION
正如文档中所说:
Note: The IsolationLevel settings will not work until next time BeginTrans is called.
这有点奇怪,但我需要以下内容:
conn.BeginTrans
... sql statement is executed here
conn.CommitTrans
甚至认为 T-SQL
语句是 SELECT
。此外,在 conn.CommitTrans
之后它仍然使用默认隔离级别(在数据库上下文中指定的级别)。