我有一个连接到SQL2008服务器的VB.net CF应用程序。我正在尝试实现事务,但是当我在事务开始时破坏代码时,某些读查询不能在表上完成。例如,从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发布于 2011-06-07 04:54:27
一旦启动了事务,记录就会被锁定,并且在提交或回滚之前都不能被访问。看看MSDN上的这个example。
此外,Data.IsolationLevel也适用于连接级别。如果你想进行脏读,你应该使用ReadUncommitted
https://stackoverflow.com/questions/5873278
复制相似问题