1
Reply

Application.Exit

CJ

CJ

Nov 8 2005 2:51 PM
1.9k
I want to exit a procedure if an exception occurs.  But this is not working. The app continues to run through the procedure. How can I make it work? 

Code:
try
   {
    sqlConnection1.Open();
   }
   catch (System.Data.SqlClient.SqlException e2)
   {
    MessageBox.Show("Exception Thrown: " + e2 + ".  Check permissions.");
    //enter code to shut down app
    this.Close();
    Application.Exit();
   }
   catch (Exception e3)
   {
    MessageBox.Show("Exception Thrown: " + e3);
    //enter code to shut down app
    this.Close();
    Application.Exit();
   }

Thanks,
cj

Answers (1)