Re: Recovering from an updatebatch error with a clone



Brian Bushay TeamB <BBushay@xxxxxxxxx> wrote:
> When you loadfromStream the connection is set to null.
> You will have to set the connection again
> In the ADO demos there is one for Briefcase mode. That is basically
> what you are doing here when you savetoStream then loadfromStream

I've watched that demo after your advice but somehow I cannot get it to
work... After retrying I keep
my old data but trying to save it I get the same error that the "row cannot
be located" because values may
have changed. Some Requery goes somewhere?

in short, the code to save the operation I am using (now with savetofile,
but same probelm) would be:

// reconnecting to connection if necessary
if dstMaster.Connection = nil then
dstMaster.Connection:=MainDataModule.conMain;

if dstDetail.Connection = nil then
dstDetail.Connection:=MainDataModule.conMain;

// here goes the transaction.
MainDataModule.conMain.BeginTrans;

dstMaster.SaveToFile('vouchm.adtg');
dstDetail.SaveToFile('vouchd.adtg');

try
// try to apply the changes.
dstMaster.UpdateBatch;
dstDetail.UpdateBatch;

if MainDataModule.conMain.InTransaction then
MainDataModule.conMain.CommitTrans;
except
on E:Exception do begin
if MainDataModule.conMain.InTransaction then
MainDataModule.conMain.RollbackTrans;

dstMaster.Connection:=nil;
dstDetail.Connection:=nil;

dstMaster.LoadFromFile('vouchm.adtg');
dstDetail.LoadFromFile('vouchd.adtg');

dstMaster.Open;
dstMaster.Edit;
dstDetail.Open;
end;
end;


--
Have you seen Marillion's Marbles? Visit www.marillion.com and get in
touch with the most amazing music...


.



Relevant Pages

  • Re: db class and connection problems
    ... One says that @connection points to ... but the object says the database connection is closed (it ... of the 'nil' object), which could only happen if your own code set ... close the database from inside the query method, ...
    (comp.lang.ruby)
  • Re: ADO connection very persistent...
    ... > The app User must be able to choose to connect to either DB. ... > ADO connection object to connect to the desired DB. ... > what the connection string says (in fact the connection string, ... You could try setting the ConnectionObject to nil - this will clean up the ...
    (borland.public.delphi.database.ado)