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;
}
}
- Run the C# code with DB2 connection string
- Before calling
scope.complete() method, the inserted value is committed in DB2 and able to be seen by querying in the DB2 table
- But the similar code for SQL connection works well