How to detect fail connection to MySql SOLUCIONADO
-
- Posts: 392
- Joined: Wed Jul 31, 2013 1:14 pm
- Location: Maldonado - Uruguay
- Contact:
How to detect fail connection to MySql SOLUCIONADO
Hi friend.
I need help to detect the fail connection to Mysql
If I do...
FWCONNECT oCon HOST chost USER cUser PASSWORD cPassword DB cdatabase
If oCon== nil
MsgInfo("No hay conexxión a la bases de datos","Informe")
Endif
First show an error from mysql-server and later my MsgInfo.
I wish to show my error message only.
Thank you.
I need help to detect the fail connection to Mysql
If I do...
FWCONNECT oCon HOST chost USER cUser PASSWORD cPassword DB cdatabase
If oCon== nil
MsgInfo("No hay conexxión a la bases de datos","Informe")
Endif
First show an error from mysql-server and later my MsgInfo.
I wish to show my error message only.
Thank you.
Last edited by D.Fernandez on Sun Jan 17, 2021 8:45 pm, edited 1 time in total.
Dario Fernandez
FWH, Harbour, BCC, MySql & MariaDB, tData, Dbf/Cdx
VSCode.
Maldonado - Uruguay
FWH, Harbour, BCC, MySql & MariaDB, tData, Dbf/Cdx
VSCode.
Maldonado - Uruguay
- nageswaragunupudi
- Posts: 8017
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Contact:
Re: How to detect fail connection to MySql
As you know, you can also write
AS
Now, add logical variable .F. as the last parameter
Now, FWH will not display the error and just returns NIL to oCn.
Then, if oCn == nil, you can query the actual error using:
On that basis you can display the error as you like.
Example:
Code: Select all
FWCONNECT oCn HOST cHost USER cUser PASSWORD cPassword DB cDatbase
Code: Select all
oCn := maria_Connect( cHost, cDatabase, cUser, cPassword )
Code: Select all
oCn := maria_Connect( cHost, cDatabase, cUser, cPassword, .F. )
Then, if oCn == nil, you can query the actual error using:
Code: Select all
aError := maria_ConnectError() // --> { nError, cErrorDescription }
Example:
Code: Select all
oCn := maria_Connect( cHost, cDatabase, cUser, cPassword, .F. )
if oCn == nil
aError := maria_ConnectError() // --> { nError, cErrorDescription }
// examine aError
MsgInfo( <your error description" )
return nil
endif
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
- nageswaragunupudi
- Posts: 8017
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Contact:
Re: How to detect fail connection to MySql
Hope you already know that FWH displays all your error messages in your language.
If you are not clear, please let us know and we will assist you.
If you are not clear, please let us know and we will assist you.
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
-
- Posts: 392
- Joined: Wed Jul 31, 2013 1:14 pm
- Location: Maldonado - Uruguay
- Contact:
Re: How to detect fail connection to MySql SOLUCIONADO
Thank you very much Mr. Rao.
Regards,
Ruben Dario Fernandez
Regards,
Ruben Dario Fernandez
Dario Fernandez
FWH, Harbour, BCC, MySql & MariaDB, tData, Dbf/Cdx
VSCode.
Maldonado - Uruguay
FWH, Harbour, BCC, MySql & MariaDB, tData, Dbf/Cdx
VSCode.
Maldonado - Uruguay
Re: How to detect fail connection to MySql SOLUCIONADO
mr. rao can explain the method, please?nageswaragunupudi wrote:Hope you already know that FWH displays all your error messages in your language.
If you are not clear, please let us know and we will assist you.
fwh 17.12, harbour 3.2.0, pelles C, bcc7, Ms-Sql
- TecniSoftware
- Posts: 213
- Joined: Fri Oct 28, 2005 6:29 pm
- Location: Quilmes, Buenos Aires, Argentina
Re: How to detect fail connection to MySql
Mr. RAO:nageswaragunupudi wrote:As you know, you can also write
Now, add logical variable .F. as the last parameterCode: Select all
oCn := maria_Connect( cHost, cDatabase, cUser, cPassword, .F. )
How can I indicate the port number?
Like D.Fernandez I would like to see a personalized message when I cannot connect to the server, in my case I use a specific port but I don't see how to indicate it in your code, normally the fourth parameter is the port number
Regards
Alejandro Cebolido
Buenos Aires, Argentina
Buenos Aires, Argentina
- nageswaragunupudi
- Posts: 8017
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Contact:
Re: How to detect fail connection to MySql SOLUCIONADO
Two ways:How can I indicate the port number?
1)
Code: Select all
oCn := maria_Connect( cHost, cDatabase, cUser, cPassword, nPort, .F. )
OR
2)
Code: Select all
oCn := maria_Connect( "hostaddress:port", cDatabase, cUser, cPassword, .F. )
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
- TecniSoftware
- Posts: 213
- Joined: Fri Oct 28, 2005 6:29 pm
- Location: Quilmes, Buenos Aires, Argentina
Re: How to detect fail connection to MySql SOLUCIONADO
As always, excellent!nageswaragunupudi wrote:Two ways:How can I indicate the port number?
1)Note: ".F." can be the last parameter after providing all parameters. Position of this parameter is not importantCode: Select all
oCn := maria_Connect( cHost, cDatabase, cUser, cPassword, nPort, .F. )
OR
2)Note: port can be a part of the address, like "nnn.nnn.nnn:port"Code: Select all
oCn := maria_Connect( "hostaddress:port", cDatabase, cUser, cPassword, .F. )
Thank you very much Mr Rao!
Alejandro Cebolido
Buenos Aires, Argentina
Buenos Aires, Argentina