Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > DB-Aware

Lost Password?

Thread Tools Display Modes
Old 10-14-2004, 04:56 PM
jalexm jalexm is offline
Junior Member
Join Date: Oct 2004
Posts: 7
Default What's the best way to handle DB errors using ADO?

I'm a beginner using Delphi/ADO and I'm creating a simple DB app using MS-Access tables.
Now I need to handle errors like key violation, invalid field values, fields that must have a value, etc. and show friendly error messages to the user. ADO/MS-Access messages are not friendly in my opinion.

So, I tried OnPostError event handler.
But I'm not sure if OnPostError event is fired only by a key violation error. If another error fires this event, my message to the user will not be correct.
In fact, I don't know how to detect exactly what kind of error happened using OnPostError.
The same problem with OnDeleteError, OnEditError, etc.

So, I tried to write a global exception handler to trap EDatabaseError and check some properties of ADOConnection Errors. The properties SQLState and NativeNumber change their values according to the errors.
But I'm not sure if these things can be used for this purpose.

Please, can you help me?
Reply With Quote
Old 10-15-2004, 01:57 AM
h1d3ki h1d3ki is offline
Senior Member
Join Date: Dec 2002
Posts: 234
Default RE: What's the best way to handle DB errors using ADO?

Have you tried using this when doing any Data processing.

// do insert or sumthing here eg. insert or edit etc...
on e : EADOError do
showmessage ( e.Message);

Hope this helps

H1D3Ki :'D
Reply With Quote

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT. The time now is 10:22 AM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2019, vBulletin Solutions, Inc.