🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: How to catch(dbExceptions ...)

#247
From: Arnie
Date: Fri, 19 Jan 2007 14:42
28 lines
1628 bytes
"Nick" <NRambarransingh@Rogers.com> wrote in message 
news:45b03c29$1@newsgroups.borland.com...
>
> Good Day all,
>
>  I am working with BCB6ent, against MSSQL2000.  There are occaisons where 
> the DB might throw an exception at me, such as "Can not insert Duplicate 
> Key".
>  OK - I am looking for an example to try/catch db errors.  What should my 
> try/catch look like?
>
> Thanks in advance,
> Nick

I suppose you could explicitly catch EDatabaseError but catching a general 
VCL exception should work fine.

query->Text = "INSERT INTO MyTable ...";
try
{
    query->ExecSQL();
}
catch ( const Exception & e )
{
    // e.Message contains the error text
}

- Arnie 
Technical Details
Message-ID: <45b0d85c$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <45b03c29$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10698b,41460225af543c7d
X-Google-Attributes: gid10698b,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Arnie" <NoOne@home.now>
Newsgroups: borland.public.cppbuilder.database.ado
References: <45b03c29$1@newsgroups.borland.com>
Subject: Re: How to catch(dbExceptions ...)
Date: Fri, 19 Jan 2007 09:42:33 -0500
Lines: 30
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.3028
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3028
X-RFC2646: Format=Flowed; Original
NNTP-Posting-Host: 198.172.234.244
Message-ID: <45b0d85c$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1169217628 198.172.234.244 (19 Jan 2007 06:40:28 -0800)
Path: arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail