🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.database.ado
Article #4381

Re: ADO (Diamond) Transaction Question...

#4381
From: Shane Stump
Date: Fri, 18 Jan 2002 22:16
84 lines
3091 bytes
Thanks.

What I decided to do instead was to create an additional set of ADOQuery
objects to perform the update. I don't like leaving transactions in an
undefined state.

Shane

"Rick Golden" <GoldenRick@hotmail.com> wrote in message
news:3c4856f8_1@dnews...
> I would suggest not to rollback
>
>         // Rollback transaction
>         _ADOConnection->RollbackTrans();
>
>  until your sure it has to be done., this way you won't loose your
> transaction.
>
> Shane Stump <ShaneStump@tanstaaflsoftware.com> wrote in message
> news:3c472d19$2_1@dnews...
> > I have a data entry form with one TdADOConnection object and two
> TdADOQuery
> > objects, two TDataSource objects, and numerous TEdit fields assoicate
with
> > both data sources.
> >
> > For my post button, I have code roughly as follows:
> >
> >
> > void __fastcall TEditForm::OnPost(void)
> > {
> >     try
> >     {
> >         // Start transaction
> >         _ADOConnection->BeginTrans();
> >
> >       // Post
> >        _ADOQuery1->Post();
> >        _ADOQuery2->Post();
> >
> >         // Commit
> >         _ADOConnection->CommTrans();
> >
> >        // Close dialog
> >        ModalResult = mrOk;
> >     }
> >
> >     // Error handling
> >     catch (Exception & objException)
> >     {
> >         // Rollback transaction
> >         _ADOConnection->RollbackTrans();
> >
> >         // Display Error
> >         InformationWindows::DisplayError(objException);
> >     }
> > }
> >
> > My problem is as follows:
> >
> > If an exception is thrown because of a CONSTRAINT error, the error is
> > displayed. If the user corrects the problem and presses the Post button
> > again, I get an exception with the following error message:
> >
> > 'ITransaction::Commit() or ITransaction::Abort() was called, and object
is
> > in a Zombie state'.
> >
> > The only solution I have is as follows:
> >
> > If an exception is thrown, copy all the current field values, reopen the
> two
> > queries, reset the user's values.
> >
> > Is there a correct (better) way, or is this it???
> >
> > Regards,
> >
> > Shane
> >
> >
> >
>
>
Technical Details
Message-ID: <3c489ed4$1_2@dnews>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!newsfeed.icl.net!skynet.be!skynet.be!newsfeed01.tsnz.net!newsfeeds.ihug.co.nz!ihug.co.nz!dnews
References: <3c472d19$2_1@dnews> <3c4856f8_1@dnews>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10698b,248edd9fe7a12b2a
X-Google-Attributes: gid10698b,public
X-Google-ArrivalTime: 2002-01-18 14:19:49 PST
From: "Shane Stump" <ShaneStump@tanstaaflsoftware.com>
Newsgroups: borland.public.cppbuilder.database.ado
References: <3c472d19$2_1@dnews> <3c4856f8_1@dnews>
Subject: Re: ADO (Diamond) Transaction Question...
Date: Fri, 18 Jan 2002 16:16:31 -0600
Lines: 86
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2600.0000
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
NNTP-Posting-Host: 205.140.147.220
Message-ID: <3c489ed4$1_2@dnews>
X-Trace: dnews 1011392212 205.140.147.220 (18 Jan 2002 14:16:52 -0800)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!newsfeed.icl.net!skynet.be!skynet.be!newsfeed01.tsnz.net!newsfeeds.ihug.co.nz!ihug.co.nz!dnews