🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: ADO (Diamond) Transaction Question...

#4379
From: Rick Golden
Date: Fri, 18 Jan 2002 17:13
70 lines
2716 bytes
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: <3c4856f8_1@dnews>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!cyclone.bc.net!logbridge.uoregon.edu!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!dnews
References: <3c472d19$2_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 09:14:41 PST
Reply-To: "Rick Golden" <GoldenRick@hotmail.com>
From: "Rick Golden" <GoldenRick@hotmail.com>
Newsgroups: borland.public.cppbuilder.database.ado
References: <3c472d19$2_1@dnews>
Subject: Re: ADO (Diamond) Transaction Question...
Date: Fri, 18 Jan 2002 12:13:14 -0500
Lines: 72
Organization: Gold
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.00.2314.1300
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300
NNTP-Posting-Host: 198.168.250.105
Message-ID: <3c4856f8_1@dnews>
X-Trace: dnews 1011373816 198.168.250.105 (18 Jan 2002 09:10:16 -0800)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!cyclone.bc.net!logbridge.uoregon.edu!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!dnews