Application.Exit after catch exception cause the app hangs
good day guys,
i came to this problem and i've googled it but i couldn't get any answer. i got an app, which connect to sql server 2000, im using try catch method in any sql event (select, insert, etc). so if the server is down, then i catch the exception and throw to a messagebox, after that Application.Exit. but the app hangs and doesn't exit the system.
any idea?
Re: Application.Exit after catch exception cause the app hangs
it would be easier to diagnose if we could see some code...:)
Re: Application.Exit after catch exception cause the app hangs
Hi,
don't attempt an insert etc if the device is not connected to the network then. If the IP address is 127.0.0.1 then the device is not connected, and warn the user they are out of range.
The device is 'hanging' as it is trying to find the server
Pete
Re: Application.Exit after catch exception cause the app hangs
Code:
public void UpdateSomething(string serialCardNo, string drinkID)
{
try
{
SqlConnection sqlConn = new SqlConnection(Global.ConnectionString);
sqlConn.Open();
SqlCommand sqlCmd = new SqlCommand("UPDATE_SOMETHING_SP",sqlConn);
sqlCmd.CommandType = CommandType.StoredProcedure;
sqlCmd.Parameters.Add(new SqlParameter("@ABC", ABC));
sqlCmd.Parameters.Add(new SqlParameter("@DEF", DEF));
sqlCmd.ExecuteNonQuery();
sqlCmd = null;
sqlConn.Close();
}
catch
{
MessageBox.Show("Couldn't connect to the server. Please check the network. Application will be terminated!");
Application.Exit();
}
}
nevermind of the exception message. the application hangs in Application.Exit();
Re: Application.Exit after catch exception cause the app hangs
Hi,
as I say, test for network connectivity before starting the operation
Pete