My application connects to a remote database via Internet. I would like to give a message to the user saying that the application is trying to connect to the database via Internet, so that the user is aware what is happening in the background and thus avoid the feeling that the app is struck and hang while it is trying to connect to the database.
This is my code which connects to the the remote database via ADO
- Code: Select all Expand view
- TRY
oApp:oConnection:Open()
CATCH oError
CursorArrow()
MsgInfo("Failed to Connect to the Database available in the Internet."+CRLF+;
"Please check whether internet is available or not in your PC","Connection failed")
ShowSqlError(oError)
RETURN .F.
END
I tried using MsgRun to show a message to the user while trying to connect. The code is given below
- Code: Select all Expand view
- TRY
MsgRun("Connecting to the server via Internet","Please wait",{ || oApp:oConnection:Open() } )
CATCH oError
CursorArrow()
MsgInfo("Failed to Connect to the Database available in the Internet."+CRLF+;
"Please check whether internet is available or not in your PC","Connection failed")
ShowSqlError(oError)
RETURN .F.
END
If the Internet connection is OK and the connection to the database is successful everything works fine as expected. But if there is a problem with the Internet or database connection, my app will wait indefinitely displaying the wait message.
I need to use TRY CATCH to trap the error. I understand that MsgRun will wait until the code block command is executed, so this will effect TRY CATCH method
Is there any other method to overcome this problem ?
Thanks & Regards
Anser