Exception handling with Delphi7

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
vortex77
Posts: 15
Joined: Wed 20 Sep 2006 11:03

Exception handling with Delphi7

Post by vortex77 » Wed 20 Sep 2006 11:15

Hi,
i'm working on app. that uses myDAC (v4.3) and Delphi7 and have question regarding myDAC except handling.
How to override myDAC exception handler? I would like to make my own handler (mostly to show my messages like 'wrong password, try again'), but in my try block myDAC already handles exceptions and my except block can't see any exception.
One example would be - entering wrong password or username while trying to connect to DB.

RH
Posts: 31
Joined: Sat 16 Sep 2006 06:32

Post by RH » Wed 20 Sep 2006 16:12

Hi

one way arround this would be to disable LoginPrompt:

try
MyConnection1.LoginPrompt:= false;
MyConnection1.Connect;
except
on E: exception do
showmessage(E.Message);
end;

then you can itercept the exception. If login prompt is enabled, then I have the same problem too. Hope this helps

kpowick
Posts: 3
Joined: Wed 20 Sep 2006 17:34
Location: Canada

Re: Exception handling with Delphi7

Post by kpowick » Wed 20 Sep 2006 17:38

vortex77 wrote:Hi,
How to override myDAC exception handler?
You can easily do this with a product like madExcept (http://www.madshi.net).

It allows you to register your own handlers for specific exceptions, thus giving you full control over the exception handling process. It's a nice product, inexpensive, great support and you can download a free trial.

--
Kevin Powick

vortex77
Posts: 15
Joined: Wed 20 Sep 2006 11:03

Post by vortex77 » Thu 21 Sep 2006 06:15

thanks.
I've tryed LoginPrompt off but it doesnt help. I'm yet to download madExcept so i hope it'll work. :?

Antaeus
Posts: 2098
Joined: Tue 14 Feb 2006 10:14

Post by Antaeus » Thu 21 Sep 2006 14:04

Try handling MyConnection.OnError event. This event is raised on all errors that concern working with server.

Post Reply