Click here to Skip to main content
15,896,557 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello, here's the scenario, when im trying to use my program to other network and that PC doesnt have internet connection, I want to catch the error as soon as possible, that will prompt that the user isn't connected to any network, coz now its throwing that it doesnt connect to MySql, and sometimes it waits and hangs to wait for the connection" i Hope someone can help me with this, BTW im using MysqldataReader to Login
Posted
Comments
PIEBALDconsult 17-Dec-15 20:51pm    
I'd just stick with saying that it can't connect to the database and not care about why. Often the Exceptions will provide more detail anyway.

1 solution

Since you need to check if there is a conection, you can use an if statement to do that, if so, proceed; otherwise show a message to avoid the hangup, use
VB
My.Computer.Network.IsAvailable()
 
Share this answer
 
Comments
Rencyrence 17-Dec-15 20:23pm    
How can i use this? please elaborate
Edgar105 18-Dec-15 13:09pm    
for example:

if My.Computer.Network.IsAvailable() then
'do all your initialization and conection procedure, etc
else
'show a message to the user there is no connection
'don´t start the mysql connection so the program does not freeze catching the error trying to connect
MessageBox.show("An internet connection is required to continue")
end if

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900