在连接到SQL 2008 DB的vb.net中,隔离级别不起作用

在连接到SQL 2008 DB的vb.net中,隔离级别不起作用,sql,vb.net,isolation-level,Sql,Vb.net,Isolation Level,我有一个VB.net CF应用程序连接到SQL 2008服务器。 我试图实现事务,但当我在事务开始时中断代码时,某些读取查询无法在表上完成。 例如,从id为123的表中选择所有记录 不会返回任何值。 但select*from stock将返回除我正在处理的行之外的所有值 Dim SQLComm As Data.SqlClient.SqlCommand Dim myConnString As String = frmConnectionDetails.GetConnectionString Dim

我有一个VB.net CF应用程序连接到SQL 2008服务器。 我试图实现事务,但当我在事务开始时中断代码时,某些读取查询无法在表上完成。 例如,从id为123的表中选择所有记录 不会返回任何值。 但select*from stock将返回除我正在处理的行之外的所有值

Dim SQLComm As Data.SqlClient.SqlCommand
Dim myConnString As String = frmConnectionDetails.GetConnectionString
Dim SQLConn As New SqlConnection(myConnString)
Dim SQLTrans As SqlTransaction
SQLConn.Open()
SQLTrans = SQLConn.BeginTransaction(Data.IsolationLevel.ReadCommitted)
SQLComm = New SqlCommand
SQLComm.Connection = SQLConn
SQLComm.Transaction = SQLTrans
AddOrUpdateStock(objStock, SQLConn, SQLComm)
 -Break here

一旦启动事务,记录将被锁定,在提交或回滚之前无法访问。在MSDN上看一下这个

此外,
Data.IsolationLevel
也适用于连接级别。如果要进行脏读,应使用
ReadUncommitted