🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.database.ado
2 messages
2 total messages Started by Nick Fri, 19 Jan 2007 03:34
How to catch(dbExceptions ...)
#246
Author: Nick
Date: Fri, 19 Jan 2007 03:34
8 lines
1037 bytes
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
Re: How to catch(dbExceptions ...)
#247
Author: 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 
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads