MyDAC - Connection - OnError
MyDAC - Connection - OnError
Hello!
I am sorry for my English
I have the next problem with OnError event at TMyConnection.
procedure TmyDataModule.MySQLConnectionError(Sender: TObject; E: EDAError; var Fail: Boolean);
begin
unit2.myDataModule.MySQLConnection.Disconnect;
// i don't know is that command necessary, but i use it to make secure
Fail:= false;
// it used don't display error message
unit3.ParamForm.ShowModal;
// show form where user can change connection parameters
// and try to connect again
end;
My problem at last command. when user change parameters and successful connecting with mysql server, then unit3.ParamForm is closed. that is all right.
But, independently of fact, was the command "Disconnect" used by me or not, Disconnect is occurs after OnError event is finished. Thus, the actions executed by the user (try to connect), was useless.
Whether, can I make so that Disconnect did not occur automatically after OnError event is finished? Or I have to use ParamForm at another procedure after OnError event?
Thank You!
I am sorry for my English
I have the next problem with OnError event at TMyConnection.
procedure TmyDataModule.MySQLConnectionError(Sender: TObject; E: EDAError; var Fail: Boolean);
begin
unit2.myDataModule.MySQLConnection.Disconnect;
// i don't know is that command necessary, but i use it to make secure
Fail:= false;
// it used don't display error message
unit3.ParamForm.ShowModal;
// show form where user can change connection parameters
// and try to connect again
end;
My problem at last command. when user change parameters and successful connecting with mysql server, then unit3.ParamForm is closed. that is all right.
But, independently of fact, was the command "Disconnect" used by me or not, Disconnect is occurs after OnError event is finished. Thus, the actions executed by the user (try to connect), was useless.
Whether, can I make so that Disconnect did not occur automatically after OnError event is finished? Or I have to use ParamForm at another procedure after OnError event?
Thank You!
In your case you do not need to handle the OnError event.
If an error arises on an open connection, then TMyConnection will do reconnect by itself. If the error arises on connecting, use the TMyConnectDialog component, or use the following code:
If an error arises on an open connection, then TMyConnection will do reconnect by itself. If the error arises on connecting, use the TMyConnectDialog component, or use the following code:
Code: Select all
try
unit2.myDataModule.MySQLConnection.Connect;
except
on E: EMyError do
unit3.ParamForm.ShowModal;
end;
Thanks for your reply.Dimon wrote:In your case you do not need to handle the OnError event. If an error arises on an open connection, then TMyConnection will do reconnect by itself. If the error arises on connecting, use the TMyConnectDialog component, or use the following code.
If the error arises on connecting, I'm using code, similar that you wrote. That is all right.
But if an error arises on an open connection, I need not TMyConnection do reconnect by itself. I want, that the user himself could solve, what to do.
Re: MyDAC - Connection - OnError
I'm too am trying to see if I can establish a valid connection.
Do I need to add something to my uses line, I get an error on EMyError, Undeclared identifier.
Do I need to add something to my uses line, I get an error on EMyError, Undeclared identifier.
Re: MyDAC - Connection - OnError
The EMyError is defined in the MyClasses.pas module. To solve the issue related with the "Undeclared identifier error:", please add the MyClasses module to the uses section of your module.
Re: MyDAC - Connection - OnError
Thanks, now compiles.
What I'm trying to do is to catch the error when trying to connect to the SQL. The user has 2 options for the SQL , Local or remote I need to catch the error If a user tries to login with the wrong source.
I'm not that clued up with the Debugger. I get
XX raised and exception class EMYSqlException with message
#xxx Access denied for user *****************
General question - How do you find what module is required when you get unidentified identifier.?
What I'm trying to do is to catch the error when trying to connect to the SQL. The user has 2 options for the SQL , Local or remote I need to catch the error If a user tries to login with the wrong source.
I'm not that clued up with the Debugger. I get
XX raised and exception class EMYSqlException with message
#xxx Access denied for user *****************
Code: Select all
procedure TfLogin.LoginClick(Sender: TObject);
begin
dm.Regisiter.Username:= eName.Text;
dm.Regisiter.Password:= ePassword.Text;
try
dm.Regisiter.connect;
except
on E: EMyError do
showMessage('Not connected');
end;
end;
Re: MyDAC - Connection - OnError
Please explain what you mean by the phrase "How do you find what module is required when you get unidentified identifier.?"
Re: MyDAC - Connection - OnError
{quote]The EMyError is defined in the MyClasses.pas module.[/quote]
So if I get an error, how do I find out what to add to my uses list ? [
So if I get an error, how do I find out what to add to my uses list ? [
Re: MyDAC - Connection - OnError
You can use MyDAC help to determine in which module the required class is declared. For example: https://devart.com/mydac/docs/devart.mydac.emyerror.htm