C# ADO.NET (System.Data.OleDb) Transaction Scope Auto Committed Before Calling Complete()
ras90it opened this issue · 1 comments
ras90it commented
`string sqlConnectionString = ""; // CONNECTION_STRING
using (TransactionScope scope = new TransactionScope())
{
try
{
using (OleDbConnection myCon = new OleDbConnection(db2ConnectionString))
{
myCon.Open();
OleDbCommand cmd = new OleDbCommand
{
CommandType = CommandType.Text,
CommandText = insertQuery, // INSERT QUERY
Connection = myCon
};
_ = cmd.ExecuteNonQuery();
scope.Complete();
}
}
catch (Exception ex)
{
throw;
}
}`
Reproduction Steps:-
- Run the C# code with the DB2 Connection String.
- Before Calling scoep.complete() method, the inserted value is committed in DB2 and able to be seen by querying in the DB2 table.
svick commented
This repo is not a good place for asking this kind of question. I think something like Stack Overflow has a much better chance of getting you the answer you're looking for.