Issue when calling connect within form's oncreate event

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
swierzbicki
Posts: 451
Joined: Wed 19 Jan 2005 09:59

Issue when calling connect within form's oncreate event

Post by swierzbicki » Wed 01 Dec 2010 12:26

Hello,

Something is going wrong when calling MyConnection.Connect within the Form's OnCreate event :
Steps to reproduce :

Create a new VCL application
Drop a TMyConnection and a TMyConnectionDialog components

Double click on the form to generate an OnCreate Event
Fill the OnCreate Event with that :

Code: Select all

Myconnection1.Connect ;
If not(MyConnection1.Connected)
     then showmessage('Ohhh noooo');
compile and run the project
when the connection dialog appears hit CANCEL

Actually :
No message is displayed (no more code from the Event is execude)

Expected :
Message should be displayed (all code from the Event should be execude)

Do you know how to solves this ?

Ps : I'm using the latest MyDac comps 6.0.0.2

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Post by AlexP » Thu 02 Dec 2010 08:57

Hello,

Thank you for the information.
We have reproduced the problem.
We are trying to resolve it.
Now you can use the following workaround:

try
Myconnection1.Connect ;
finally
If not(MyConnection1.Connected)
then showmessage('Ohhh noooo');
end;

bork
Devart Team
Posts: 649
Joined: Fri 12 Mar 2010 07:55

Post by bork » Thu 02 Dec 2010 10:05

Hello

We have fixed this problem. This fix will be included in the next MyDAC build.

bork
Devart Team
Posts: 649
Joined: Fri 12 Mar 2010 07:55

Post by bork » Fri 03 Dec 2010 09:19

Hello

We have analyzed this issue again. We cannot change this behavior because other our users use try...except block to catch situations when connection wasn't established. So you should use try...except or try...finally blocks to handle the "Cancel" button click.

swierzbicki
Posts: 451
Joined: Wed 19 Jan 2005 09:59

Post by swierzbicki » Fri 03 Dec 2010 16:35

Hello,


when doing so, I don't know if the connection wasn't established because of network/authentification errors or because of user who hit Cancel button.

I also understand that an exception is raised when an errors occurs but I don't get why you raise a silent (EAbort) exception when a user click on Cancel ?

bork
Devart Team
Posts: 649
Joined: Fri 12 Mar 2010 07:55

Post by bork » Tue 07 Dec 2010 08:22

Hello

I understand your issue and I agree with you. But we have a lot of users that are using the current behavior. We will try to find a solution for it.

swierzbicki
Posts: 451
Joined: Wed 19 Jan 2005 09:59

Post by swierzbicki » Wed 08 Dec 2010 07:29

Thank you !

Post Reply