IBM / Db2

Db2 Universal Container deployment
Apache License 2.0
9 stars 34 forks source link

C# ADO.NET (IBM.Data.DB2.Core) Transaction Scope Auto Committed Before Calling Complete() #45

Open ras90it opened 1 year ago

ras90it commented 1 year ago

string db2ConnectionString = ""; string insertQuery = ""; // INSERT QUERY

using (TransactionScope scope = new TransactionScope()) { try {

    using (DB2Connection myCon = new DB2Connection(db2ConnectionString))
    {
        myCon.Open();

        DB2Command cmd = new DB2Command()
        {
            CommandType = CommandType.Text,
            CommandText = insertQuery, // INSERT QUERY
            Connection = myCon
        };

        _ = cmd.ExecuteNonQuery();

    }
}
catch (Exception ex)
{
    throw;
}

}

Reproduction Steps:-

  1. Run the C# code with the DB2 Connection String.
  2. Before Calling scope.complete() method, the inserted value is committed in DB2 and able to be seen by querying in the DB2 table.