protected void updateConnection(object sender, CommandEventArgs e) { Button sendBtn = (Button)sender; String args = sendBtn.CommandArgument.ToString(); ConnInfo tempConnInfo = new ConnInfo(); tempConnInfo.setConnectionName(editConnName.Text); tempConnInfo.setDatabaseName(editConnDBName.Text); tempConnInfo.setServerAddress(editConnDBAddr.Text); tempConnInfo.setPortNumber(editConnDBPort.Text); tempConnInfo.setUserName(editConnUser.Text); tempConnInfo.setPassword(editConnPass.Text); tempConnInfo.setDatabaseType((editConnDBType.SelectedIndex)); tempConnInfo.setOracleProtocol(editOracleProtocol.Text); tempConnInfo.setOracleServiceName(editOracleService.Text); tempConnInfo.setOracleSID(editOracleSID.Text); //If the connection information is bad, report the error and cancel the function. This does NOT run against the database. try { if (!tempConnInfo.isValid(Convert.ToInt32(args))) { throw new ODBC2KMLException(""); // Throw any error. The catch is generic. } } catch { String error = "The entered connection information is invalid. Please make sure all fields are filled and that they are in proper format."; if (tempConnInfo.getDatabaseType() == ConnInfo.ORACLE) { error = "The entered connection information is invalid. Please verify that all fields have a value and the value is of proper type." + " Also, make sure that Oracle SID or Oracle Service Name and Oracle Protocol have been entered."; } ErrorHandler eh = new ErrorHandler(error, errorPanel1); this.editConnModalPopUp.Hide(); eh.displayError(); return; } //Create database and test it Database db = new Database(tempConnInfo); //See if you can reach the database. If not, error out and don't save. try { if (tempConnInfo.getDatabaseType() == ConnInfo.MSSQL) { String query = "SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA != 'information_schema' AND TABLE_NAME != 'sysdiagrams'"; db.executeQueryRemote(query); } else if (tempConnInfo.getDatabaseType() == ConnInfo.MYSQL) { String query = "SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA != 'information_schema' && TABLE_SCHEMA != 'mysql'"; db.executeQueryRemote(query); } else if (tempConnInfo.getDatabaseType() == ConnInfo.ORACLE) { String query = "select TABLE_NAME from user_tables"; db.executeQueryRemote(query); } } catch { ErrorHandler eh = new ErrorHandler("The database entered could not be connected to. Please verify the information is correct.", errorPanel1); this.editConnModalPopUp.Hide(); eh.displayError(); return; } db.executeQueryLocal("UPDATE Connection SET name='" + tempConnInfo.getConnectionName() + "', dbName='" + tempConnInfo.getDatabaseName() + "', userName='******', password='******', port='" + tempConnInfo.getPortNumber() + "', address='" + tempConnInfo.getServerAddress() + "', type='" + tempConnInfo.getDatabaseType() + "', protocol='" + tempConnInfo.getOracleProtocol() + "', serviceName='" + tempConnInfo.getOracleServiceName() + "', SID='" + tempConnInfo.getOracleSID() + "' WHERE (ID='" + args + "')"); Connection conn = new Connection(Convert.ToInt16(args)); try { conn.populateFields(); //Force the connection into a safe state, if it is not if (!conn.safeStateConnection()) { String error = "Invalid connection information. Please verify all of your fields are filled in correctly." + "If you are using an oracle connection, please make sure you filled out the oracle specific information."; ErrorHandler eh = new ErrorHandler(error, errorPanel1); this.editConnModalPopUp.Hide(); eh.displayError(); return; } } catch (ODBC2KMLException err) { ErrorHandler eh = new ErrorHandler(err.errorText, errorPanel1); this.editConnModalPopUp.Hide(); eh.displayError(); return; } if (e.CommandName.Equals("saveConn")) { this.editConnModalPopUp.Hide(); Response.Redirect("Main.aspx"); } else { this.editConnModalPopUp.Hide(); Response.Redirect("ConnDetails.aspx?ConnID=" + ((Button)sender).CommandArgument.ToString() + "&locked=false"); } }