Article View: borland.public.cppbuilder.database.ado
Article #4068ADO and Exceptions
From: Jeff
Date: Mon, 08 Apr 2002 10:17
Date: Mon, 08 Apr 2002 10:17
28 lines
1911 bytes
1911 bytes
I hope someone out there can help. I've worked on it all day and can't get
it to work.
I have a TADOTable on a form called tblList that is connected to an
Access2000 table called 'Reason Codes', set at design time in the
properties. I use a TADOConnection in a Data Module. tblList is displayed in
a TDBGrid via a TDataSource(dsList). Here's the code:
AnsiString NewCode = "1019";
AnsiString NewDescription = "Some Reason";
try {
tblList->Append();
tblList->FieldByName("Code")->AsInteger = StrToInt(NewCode);
tblList->FieldByName("Description")->AsString = NewDescription;
tblList->Post();
} catch(...) {
ShowMessage("Code already used.");
tblList->Cancel();
}
The 'Code' field is the Primary Key. When I try to post a Code that is
already used, I get to exceptions that are displayed (EOleException &
EDatatbaseError) BEFORE the catch block is executed. I have tried an
OnPostError() event and nothing will stop the first two exceptions from
being displayed before going to my handler(s). What gives?
Jeff.
Technical Details
Message-ID:
<3cb16e2f$1_2@dnews>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!supernews.com!news.infoave.net!skynet.be!skynet.be!newsfeed.online.be!fu-berlin.de!news.boerde.de!nntp.cs.uni-magdeburg.de!PeerFeed.KWeb.on.ca!dnewsShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10698b,b813aadf97a66fb7,start X-Google-Attributes: gid10698b,public X-Google-ArrivalTime: 2002-04-08 03:18:14 PST From: "Jeff" <jkofsky@bellsouth.net> Newsgroups: borland.public.cppbuilder.database.ado Subject: ADO and Exceptions Date: Mon, 8 Apr 2002 05:17:19 -0500 Lines: 31 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: 65.80.160.188 Message-ID: <3cb16e2f$1_2@dnews> X-Trace: dnews 1018261039 65.80.160.188 (8 Apr 2002 03:17:19 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!supernews.com!news.infoave.net!skynet.be!skynet.be!newsfeed.online.be!fu-berlin.de!news.boerde.de!nntp.cs.uni-magdeburg.de!PeerFeed.KWeb.on.ca!dnews