SqlCeTransaction.Commit メソッドとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > SqlCeTransaction.Commit メソッドの意味・解説 

SqlCeTransaction.Commit メソッド (CommitMode)

指定された CommitMode を使用してデータベース トランザクションコミットます。

名前空間: System.Data.SqlServerCe
アセンブリ: System.Data.SqlServerCe (system.data.sqlserverce.dll 内)
構文構文

Public Sub Commit ( _
    mode As CommitMode _
)
Dim instance As SqlCeTransaction
Dim mode As CommitMode

instance.Commit(mode)
public void Commit (
    CommitMode mode
)
public:
void Commit (
    CommitMode mode
)
public void Commit (
    CommitMode mode
)
public function Commit (
    mode : CommitMode
)

パラメータ

mode
例外例外
使用例使用例

SqlCeConnection および SqlCeTransaction を作成する例を次に示します。BeginTransaction、CommitRollback の各メソッド使い方示します

Dim conn As New SqlCeConnection("Data
 Source = AdventureWorks.sdf;")
conn.Open()

' Start a local transaction; SQL Mobile supports the following 
' isolation levels: ReadCommitted, RepeatableRead, Serializable
'
Dim tx As SqlCeTransaction = conn.BeginTransaction(IsolationLevel.ReadCommitted)

' By default, commands run in auto-commit mode; 
'
Dim cmd1 As SqlCeCommand = conn.CreateCommand()

' You may create multiple commands on the same connection
'
Dim cmd2 As SqlCeCommand = conn.CreateCommand()

' To enlist a command in a transaction, set the Transaction property
'
cmd1.Transaction = tx

Try
    cmd1.CommandText = "INSERT INTO FactSalesQuota "
 & _
        "(EmployeeKey, TimeKey, SalesAmountQuota) "
 & _
        "VALUES (2, 1158, 150000.00)"

    cmd1.ExecuteNonQuery()

    ' Auto-commited because cmd2 is not enlisted in a transaction
    '
    cmd2.CommandText = "INSERT INTO FactSalesQuota "
 & _
        "(EmployeeKey, TimeKey, SalesAmountQuota) "
 & _
        "VALUES (3, 1157, 15000.00)"

    cmd2.ExecuteNonQuery()

    ' Commit the changes to disk if everything above succeeded;
    ' Use Deferred mode for optimal performance; the changes will 
    ' be flashed to disk within the timespan specified in the 
    ' ConnectionString 'FLUSH INTERVAL' property; 
    '
    tx.Commit(CommitMode.Deferred)

    ' Alternatively, you could use:
    ' tx.Commit(CommitMode.Immediate);
    '
    ' or use default (Deferred) commit mode:
    ' tx.Commit()

Catch e As Exception
    ' Handle errors here
    '
    tx.Rollback()
Finally
    conn.Close()
End Try
SqlCeConnection conn = new SqlCeConnection("Data Source =
 AdventureWorks.sdf;");
conn.Open();

// Start a local transaction; SQL Mobile supports the following 
// isolation levels: ReadCommitted, RepeatableRead, Serializable
//
SqlCeTransaction tx = conn.BeginTransaction(IsolationLevel.ReadCommitted);

// By default, commands run in auto-commit mode; 
//
SqlCeCommand cmd1 = conn.CreateCommand();

// You may create multiple commands on the same connection
//
SqlCeCommand cmd2 = conn.CreateCommand();

// To enlist a command in a transaction, set the Transaction property
//
cmd1.Transaction = tx;

try
{
    cmd1.CommandText = "INSERT INTO FactSalesQuota " +
        "(EmployeeKey, TimeKey, SalesAmountQuota) " +
        "VALUES (2, 1158, 150000.00)";

    cmd1.ExecuteNonQuery();

    // Auto-commited because cmd2 is not enlisted in a transaction
    //
    cmd2.CommandText = "INSERT INTO FactSalesQuota " +
        "(EmployeeKey, TimeKey, SalesAmountQuota) " +
        "VALUES (3, 1157, 15000.00)";

    cmd2.ExecuteNonQuery();

    // Commit the changes to disk if everything above succeeded;
    // Use Deferred mode for optimal performance; the changes will 
    // be flashed to disk within the timespan specified in the 
    // ConnectionString 'FLUSH INTERVAL' property; 
    //
    tx.Commit(CommitMode.Deferred);

    // Alternatively, you could use:
    // tx.Commit(CommitMode.Immediate);
    //
    // or use default (Deferred) commit mode:
    // tx.Commit()
}
catch (Exception)
{
    // Handle errors here
    //
    tx.Rollback();
}
finally
{
    conn.Close();
}
.NET Framework のセキュリティ.NET Frameworkセキュリティ
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
SqlCeTransaction クラス
SqlCeTransaction メンバ
System.Data.SqlServerCe 名前空間
BeginTransaction
Rollback

SqlCeTransaction.Commit メソッド


SqlCeTransaction.Commit メソッド ()

データベース トランザクションコミットます。

名前空間: System.Data.SqlServerCe
アセンブリ: System.Data.SqlServerCe (system.data.sqlserverce.dll 内)
構文構文

例外例外
使用例使用例

SqlCeConnection および SqlCeTransaction を作成する例を次に示します。BeginTransaction、CommitRollback の各メソッド使い方示します

Dim conn As New SqlCeConnection("Data
 Source = AdventureWorks.sdf;")
conn.Open()

' Start a local transaction; SQL Mobile supports the following 
' isolation levels: ReadCommitted, RepeatableRead, Serializable
'
Dim tx As SqlCeTransaction = conn.BeginTransaction(IsolationLevel.ReadCommitted)

' By default, commands run in auto-commit mode; 
'
Dim cmd1 As SqlCeCommand = conn.CreateCommand()

' You may create multiple commands on the same connection
'
Dim cmd2 As SqlCeCommand = conn.CreateCommand()

' To enlist a command in a transaction, set the Transaction property
'
cmd1.Transaction = tx

Try
    cmd1.CommandText = "INSERT INTO FactSalesQuota "
 & _
        "(EmployeeKey, TimeKey, SalesAmountQuota) "
 & _
        "VALUES (2, 1158, 150000.00)"

    cmd1.ExecuteNonQuery()

    ' Auto-commited because cmd2 is not enlisted in a transaction
    '
    cmd2.CommandText = "INSERT INTO FactSalesQuota "
 & _
        "(EmployeeKey, TimeKey, SalesAmountQuota) "
 & _
        "VALUES (3, 1157, 15000.00)"

    cmd2.ExecuteNonQuery()

    ' Commit the changes to disk if everything above succeeded;
    ' Use Deferred mode for optimal performance; the changes will 
    ' be flashed to disk within the timespan specified in the 
    ' ConnectionString 'FLUSH INTERVAL' property; 
    '
    tx.Commit(CommitMode.Deferred)

    ' Alternatively, you could use:
    ' tx.Commit(CommitMode.Immediate);
    '
    ' or use default (Deferred) commit mode:
    ' tx.Commit()

Catch e As Exception
    ' Handle errors here
    '
    tx.Rollback()
Finally
    conn.Close()
End Try
SqlCeConnection conn = new SqlCeConnection("Data Source =
 AdventureWorks.sdf;");
conn.Open();

// Start a local transaction; SQL Mobile supports the following 
// isolation levels: ReadCommitted, RepeatableRead, Serializable
//
SqlCeTransaction tx = conn.BeginTransaction(IsolationLevel.ReadCommitted);

// By default, commands run in auto-commit mode; 
//
SqlCeCommand cmd1 = conn.CreateCommand();

// You may create multiple commands on the same connection
//
SqlCeCommand cmd2 = conn.CreateCommand();

// To enlist a command in a transaction, set the Transaction property
//
cmd1.Transaction = tx;

try
{
    cmd1.CommandText = "INSERT INTO FactSalesQuota " +
        "(EmployeeKey, TimeKey, SalesAmountQuota) " +
        "VALUES (2, 1158, 150000.00)";

    cmd1.ExecuteNonQuery();

    // Auto-commited because cmd2 is not enlisted in a transaction
    //
    cmd2.CommandText = "INSERT INTO FactSalesQuota " +
        "(EmployeeKey, TimeKey, SalesAmountQuota) " +
        "VALUES (3, 1157, 15000.00)";

    cmd2.ExecuteNonQuery();

    // Commit the changes to disk if everything above succeeded;
    // Use Deferred mode for optimal performance; the changes will 
    // be flashed to disk within the timespan specified in the 
    // ConnectionString 'FLUSH INTERVAL' property; 
    //
    tx.Commit(CommitMode.Deferred);

    // Alternatively, you could use:
    // tx.Commit(CommitMode.Immediate);
    //
    // or use default (Deferred) commit mode:
    // tx.Commit()
}
catch (Exception)
{
    // Handle errors here
    //
    tx.Rollback();
}
finally
{
    conn.Close();
}
.NET Framework のセキュリティ.NET Frameworkセキュリティ
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
SqlCeTransaction クラス
SqlCeTransaction メンバ
System.Data.SqlServerCe 名前空間
BeginTransaction
Rollback


このページでは「.NET Framework クラス ライブラリ リファレンス」からSqlCeTransaction.Commit メソッドを検索した結果を表示しています。
Weblioに収録されているすべての辞書からSqlCeTransaction.Commit メソッドを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からSqlCeTransaction.Commit メソッド を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

SqlCeTransaction.Commit メソッドのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



SqlCeTransaction.Commit メソッドのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2024 Microsoft.All rights reserved.

©2024 GRAS Group, Inc.RSS