Diese Seite mit anderen teilen ...

Informationen zum Thema:
Forum:
WinDev Forum
Beiträge im Thema:
6
Erster Beitrag:
vor 10 Monaten, 3 Wochen
Letzter Beitrag:
vor 10 Monaten, 3 Wochen
Beteiligte Autoren:
Binod Lohani, Fabrice Harari, DW

Check if database connection is still active

Startbeitrag von Binod Lohani am 23.09.2016 10:00

Hello Everyone !!

A) Say I am connected to MySQL via internet (using Native Access).
and somehow my internet connection is lost for some minutes and then again connected !! What would happen then ?? is my connection to database still active ?? or lost ??
NOTE that I have not called Hcloseconnection ()

B) Is there anything like HCheckConnection(connection_variable) which would return true if a connection to a specific database is still active and false if the connection is lost ..
In other word How do We know if the database handshake is still there.

Thanks !!

Antworten:

Hi

well, you'll get an error on ANY DB function that you call if you lost the connection. So there is no need for an EXTRA processing, you just need to manage your errors correctly on each DB access function, which you should be doing already in any case. The error number will let you know that you are in this specific case.

Best regards

von Fabrice Harari - am 23.09.2016 11:30
Wow!!
Thanks Fabrice Harari !
By the way what would be the error number if the connection is lost ??
Thanks !

von Binod Lohani - am 23.09.2016 12:07
Hi

connect to your DB
unplug the network
display the error code

Best regards

von Fabrice Harari - am 23.09.2016 12:51
Bindod



PROCEDURE gp_ConnectionErrors()
sErrorMessage is string
SWITCH HError()
CASE 74000
sErrorMessage = "74000 the program could not connect to the server"
CASE 74001
sErrorMessage ="74001 User name or Password is incorrect"
CASE 73205
sErrorMessage ="73205 The IP Address is incorrect or blocked"
CASE 73250
sErrorMessage ="73205 The IP Address is incorrect or blocked"
CASE 70202
sErrorMessage ="70202 The IP Address is incorrect or blocked"+CR+CR+"Check your firewall settings and IP Address and try again."
OTHER CASE
sErrorMessage ="An error occurred in the window" +ExceptionInfo(errMessage)
END

RESULT = sErrorMessage


von DW - am 24.09.2016 00:22
Thanks DW !!

von Binod Lohani - am 24.09.2016 01:42
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.