Article View: borland.public.cppbuilder.database.ado
Article #4378ADO (Diamond) Transaction Question...
From: Shane Stump
Date: Thu, 17 Jan 2002 19:59
Date: Thu, 17 Jan 2002 19:59
55 lines
2299 bytes
2299 bytes
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:
<3c472d19$2_1@dnews>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!news.tele.dk!small.news.tele.dk!4.1.16.34!cpk-news-hub1.bbnplanet.com!news.gtei.net!newsfeed1.cidera.com!Cidera!netnews.com!xfer02.netnews.com!newsfeed.wirehub.nl!PeerFeed.KWeb.on.ca!dnewsShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10698b,248edd9fe7a12b2a,start X-Google-Attributes: gid10698b,public X-Google-ArrivalTime: 2002-01-17 12:02:08 PST From: "Shane Stump" <ShaneStump@tanstaaflsoftware.com> Newsgroups: borland.public.cppbuilder.database.ado Subject: ADO (Diamond) Transaction Question... Date: Thu, 17 Jan 2002 13:59:02 -0600 Lines: 58 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: <3c472d19$2_1@dnews> X-Trace: dnews 1011297561 205.140.147.220 (17 Jan 2002 11:59:21 -0800) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!news.tele.dk!small.news.tele.dk!4.1.16.34!cpk-news-hub1.bbnplanet.com!news.gtei.net!newsfeed1.cidera.com!Cidera!netnews.com!xfer02.netnews.com!newsfeed.wirehub.nl!PeerFeed.KWeb.on.ca!dnews