Exemplo n.º 1
0
 private void btnDatabaseEngineTestConnection_Click(object sender, EventArgs e)
 {
     try {
         syncConnectionInfoToGUI(null);
         var    proxy         = new AdminHostProxy(_conn, true);
         string failureReason = proxy.TestDatabaseConnection();
         if (!String.IsNullOrEmpty(failureReason))
         {
             MessageBox.Show(this, failureReason, getDisplayMember("testDbConnection{failed_title}", "Connection Failed"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         }
         else
         {
             MessageBox.Show(this, getDisplayMember("testDbConnection{success_body}", "Connection Succeeded."),
                             getDisplayMember("testDbConnection{success_title}", "Valid Connection"), MessageBoxButtons.OK, MessageBoxIcon.None);
         }
     } catch (InvalidCredentialException ice) {
         Debug.WriteLine(ice.Message);
         MessageBox.Show(this, getDisplayMember("testDbConnection{noadmin_body}", "Successfully connected to database engine.\n\nHowever, you must also specify a valid GRIN-Global Login with administrative rights to perform administrative tasks."),
                         getDisplayMember("testDbConnection{noadmin_title}", "Database Engine Connection Success"));
         txtGrinGlobalUserName.Focus();
         txtGrinGlobalUserName.Select();
     } catch (Exception ex) {
         MessageBox.Show(this, getDisplayMember("testDbConnection{completefail_body}", "Unable to contact the database engine.  Please verify the connection information is correct and your credentials are valid.\n\n{0}", ex.Message),
                         getDisplayMember("testDbConnection{noadmin_title}", "Unable to Contact Database Engine"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
     }
 }