Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 2 of 2 total
Thread Transaction / Cannot perform this operation on a closed database
Fri, Jan 11 2013 6:53 PMPermanent Link

IQA

Hi All,

Wondering if anyone would know of a reason why a TRANSACTION would cause
the Database to close?

If I remove the transaction lines of code so its no longer running in a
transaction, then all the records are added perfectly in the FOR loop as
expected. But as soon a I have it running in a transaction, the database
is disconnected after the first INSERT.


Basically here's a simplistic idea of what I have:

// Connect database
CDSDatabase->Connected = true;

CDSDatabase->StartTransaction(Tables);

try
{
  for (int x = 0; x < whatever; x++)
  {
    EDBQuery being used to insert a record
            
    // PROBLEM occurs here after FIRST record is inserted, then raises
the error: "Cannot perform this operation on a closed database"
  }
   
  CDSDatabase->Commit();
}
catch (Exception &exception)
{
  CDSDatabase->Rollback();
}

// Disconnect database
CDSDatabase->Connected = false;

Fri, Jan 11 2013 10:24 PMPermanent Link

IQA

All good, I found the problem was the database was closing automatically
during the transaction, because I had the EDBDatabase->KeepConnection =
false (which I have set for a reason in the program)... So just for this
function I set the KeepConnection = true and it works as expected.

Cheers! Wink
Image