1

我为数据库操作开发 DAL 类

 Public Sub StartTransaction()
    Dim objConnection As SqlConnection = EstablishConnection()
    objConnection.Open()
    Me.Transaction = objConnection.BeginTransaction()
End Sub

Public Sub CommitTransaction()
    Me.Transaction.Commit()
End Sub

Public Sub RollBackTransaction()
    Me.Transaction.Rollback()
End Sub

在我们提交或回滚时启动事务并将事务对象设置为空后它不会关闭与此事务的连接附加我如何关闭连接到此事务的附加???

4

2 回答 2

1

你有没有尝试过:

objConnection.Close()

也许您需要在该函数之外声明 de sqlConnection 以便您可以访问变量以将其关闭。

于 2013-07-03T05:14:51.153 回答
1

试试这个

Public Sub CommitTransaction()
  Me.Transaction.Commit()
  Me.objConnection.Close()
End Sub

Public Sub RollBackTransaction()
  Me.Transaction.Rollback()
  Me.objConnection.Close()
End Sub
于 2013-07-03T05:37:35.073 回答