"A connection with the transaction manager was lost"

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Jeff Gallant
Posts: 5
Joined: Wed 22 Oct 2008 16:08
Location: London

"A connection with the transaction manager was lost"

Post by Jeff Gallant » Mon 29 Dec 2008 15:16

SDAC 4.70
Delphi 2006

I am trying to follow the advice given for my previous issue in this forum (Simple multi-user problem locks/transactions)

I have the following code:

txnNextCB.AddConnection(qryNextCB.Connection);
txnNextCB.StartTransaction;
qryNextCB.open;

where txnNextCB is a TMStransaction and qryNextCB is a TMSquery.

txnNextCB has been put on the form with all the defaults apart from its name and this is the first time it is referenced - no other connections have been added.

When I run the code, I get:

"A connection with the transaction manager was lost"

If I comment out the code referring to the transaction

// txnNextCB.AddConnection(qryNextCB.Connection);
// txnNextCB.StartTransaction;
qryNextCB.open;

the query runs okay indicating that qryNextCB.Connection is connected and works.

What am I doing wrong?

Dimon
Devart Team
Posts: 2885
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Tue 30 Dec 2008 12:23

I can not reproduce the problem.
Please check if the following code works:

Code: Select all

  qryNextCB.Connection.StartTransaction;
  qryNextCB.open;

Jeff Gallant
Posts: 5
Joined: Wed 22 Oct 2008 16:08
Location: London

"A connection with the transaction manager was lost"

Post by Jeff Gallant » Wed 31 Dec 2008 09:35

Thanks Dimon, that got me through that point but now my code is:

txnNextCB.AddConnection(qryNextCB.Connection);
qryNextCB.Connection.StartTransaction;
qryNextCB.open;
qryNextCB.Lock(ltExclusive);

some other code that uses FieldByName to capture data from the selected record

qryUpdateCB.Connection:=qryNextCB.Connection;
qryUpdateCB.execute; // Updates record selected by qryNextCB
qryNextCB.Connection.Commit;
qryNextCB.UnLock;

However, when it executes the unlock I get

“the ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION”

I've obviously still not got the hang of this.

What I am trying to do is prevent anyone else successfully selecting and locking this record until after the update is posted (the update changes the record so qryNextCB's where clause would no longer select it) so I cannot unlock the record until after the update is committed.

Assuming no-one responds today, may I wish you all a happy new year and hope that I can get this resolved early in 2009.

Best wishes

Jeff

Dimon
Devart Team
Posts: 2885
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Mon 05 Jan 2009 09:21

The point is that the record lock is automatically released when the transaction is committed or rolled back. Therefore you should not execute the UnLock method after executing Connection.Commit.

Post Reply