メイン コンテンツへスキップ
サポート
Microsoft アカウントでサインイン
サインインまたはアカウントを作成してください。
こんにちは、
別のアカウントを選択してください。
複数のアカウントがあります
サインインに使用するアカウントを選択してください。

この記事では、次の Microsoft .NET Framework クラス ライブラリ名前空間について説明します。

  • System.Data

  • System.Data.OleDb

  • System.Data.SqlClient

現象

ADO.NET で Microsoft OLE DB Provider for SQL Server (OLEDBSQL) を使用すると、セッションで複数のトランザクションを開始しようとすると、次のエラー メッセージが表示されます。

System.Data.OleDb.OleDbException: このセッションで他のトランザクションを開始できません

原因

設計上、入れ子になったトランザクションSQL Server OLE DB プロバイダーは許可できません。

詳細情報

現象の再現手順

  1. .NET Microsoft Visual Studio開始します。

  2. .NET Windowsアプリケーション プロジェクトを作成Visual Basicします。 Form1 は既定で作成されます。

  3. [Form1] をダブルクリックして [コード] ウィンドウを開きます。

  4. 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
  5. 環境に応じて接続文字列を変更します。

  6. アプリケーションを実行します。 「現象」セクションに記載されているエラーが表示されます。

参照情報

詳細については、以下の記事番号をクリックして、Microsoft サポート技術情報の記事を表示します。

306649 PRB: OLE DB プロバイダーで入れ子になったトランザクションを実装するときにエラーが発生SQLプロバイダー

ヘルプを表示

その他のオプションが必要ですか?

サブスクリプションの特典の参照、トレーニング コースの閲覧、デバイスのセキュリティ保護方法などについて説明します。

コミュニティは、質問をしたり質問の答えを得たり、フィードバックを提供したり、豊富な知識を持つ専門家の意見を聞いたりするのに役立ちます。

この情報は役に立ちましたか?

言語の品質にどの程度満足していますか?
どのような要因がお客様の操作性に影響しましたか?
[送信] を押すと、Microsoft の製品とサービスの改善にフィードバックが使用されます。 IT 管理者はこのデータを収集できます。 プライバシーに関する声明。

フィードバックをいただき、ありがとうございます。

×