이 문서에서는 다음 Microsoft .NET Framework 클래스 라이브러리 네임스페이스를 참조합니다.
-
System.Data
-
System.Data.OleDb
-
System.Data.SqlClient
증상
Microsoft OLE DB 공급자를 SQL Server(OLEDBSQL)ADO.NET 세션에서 두 개 이상의 트랜잭션을 시작하려고 하는 경우 다음 오류 메시지가 표시됩니다.
System.Data.OleDb.OleDbException: 이 세션에서 더 많은 트랜잭션을 시작할 수 없습니다.
원인
설계상 OLE DB 공급자는 SQL Server 중첩된 트랜잭션을 허용하지 않습니다.
추가 정보
동작을 재현하는 단계
-
.NET Microsoft Visual Studio 시작합니다.
-
.NET에서 Windows 애플리케이션 프로젝트를 Visual Basic. Form1은 기본적으로 만들어집니다.
-
Form1을 두 번 클릭하여 코드 창을 니다.
-
Form1의 코드를 다음 코드로 바 대체합니다.
Imports System.Data
Imports System.Data.OleDb
Imports System.Data.SqlClient
Public Class Form1
Inherits System.Windows.Forms.Form
Dim cn As New OleDb.OleDbConnection()
Dim cmd As New OleDb.OleDbCommand()
Dim mycmd As New OleDb.OleDbCommand()
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.Container
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(292, 273)
Me.Name = "Form1"
Me.Text = "Form1"
End Sub
#End Region
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
cn.ConnectionString = "Provider=SQLOLEDB;Data Source=YourServer;" & _
"Initial Catalog=pubs;User ID=YourUserID;Password=YourPassword"
cn.Open()
cmd.Connection = cn
mycmd.Connection = cn
cmd.CommandText = "Insert into stores (stor_id) values('9876')"
Dim myTrans As OleDb.OleDbTransaction
myTrans = cn.BeginTransaction(IsolationLevel.ReadCommitted)
cmd.Transaction = myTrans
Try
cmd.ExecuteNonQuery()
myTrans.Begin()
myTrans.Commit()
Catch ex As Exception
MessageBox.Show(ex.ToString)
End Try
End Sub
End Class -
환경에 적합한 연결 문자열을 수정합니다.
-
애플리케이션을 실행합니다. "증상" 섹션에 나열된 오류가 표시됩니다.
참조
자세한 내용은 아래 문서 번호를 클릭하여 Microsoft 기술 자료에서 문서를 볼 수 있습니다.
306649 PRB: OLE DB 공급자를 통해 중첩된 트랜잭션을 구현할 때 오류 SQL 공급자