private void button1_Click_1(object sender, EventArgs e) { XmlDocument fichero = new XmlDocument(); fichero.Load("localizacion.xml"); // Comprobamos que los valores mínimos y necesarios estén definidos if ((this.server.Text.Length > 0) && (this.server.Text != fichero.SelectSingleNode("/localizacion/en/ventanaconexion/textServer").InnerText) && (this.server.Text != fichero.SelectSingleNode("/localizacion/es/ventanaconexion/textServer").InnerText)) { if (this.user.TextLength > 0) { if (this.ddbb.TextLength > 0) { string ConnectionString; // Definimos la ristra de conexión y se la enviamos a la ventana principal if ((this.port.TextLength > 0) && (this.port.Text != fichero.SelectSingleNode("/localizacion/es/ventanaconexion/textPort").InnerText) && (this.port.Text != fichero.SelectSingleNode("/localizacion/en/ventanaconexion/textPort").InnerText)) { ConnectionString = "SERVER=" + this.server.Text + "; PORT=" + this.port.Text; } else { ConnectionString = "SERVER=" + this.server.Text; } ConnectionString += "; DATABASE=" + this.ddbb.Text + "; Uid=" + this.user.Text + ";"; if (this.pass.TextLength > 0) { ConnectionString += " PWD='" + this.pass.Text + "';"; } ConnectionString += "Encrypt=true;"; form.setConnectionString(ConnectionString, this.ddbb.Text, this.server.Text); form.Conectar(sender, e); } else { if (idioma) { MessageBox.Show(fichero.SelectSingleNode("/localizacion/es/ventanaconexion/errorDDBB1").InnerText, fichero.SelectSingleNode("/localizacion/es/ventanaconexion/errorDDBB2").InnerText); } else { MessageBox.Show(fichero.SelectSingleNode("/localizacion/en/ventanaconexion/errorDDBB1").InnerText, fichero.SelectSingleNode("/localizacion/en/ventanaconexion/errorDDBB2").InnerText); } } } else { if (idioma) { MessageBox.Show(fichero.SelectSingleNode("/localizacion/es/ventanaconexion/errorUsuario1").InnerText, fichero.SelectSingleNode("/localizacion/es/ventanaconexion/errorUsuario2").InnerText); } else { MessageBox.Show(fichero.SelectSingleNode("/localizacion/en/ventanaconexion/errorUsuario1").InnerText, fichero.SelectSingleNode("/localizacion/en/ventanaconexion/errorUsuario2").InnerText); } } } else { if (idioma) { MessageBox.Show(fichero.SelectSingleNode("/localizacion/es/ventanaconexion/errorServidor1").InnerText, fichero.SelectSingleNode("/localizacion/es/ventanaconexion/errorServidor2").InnerText); } else { MessageBox.Show(fichero.SelectSingleNode("/localizacion/en/ventanaconexion/errorServidor1").InnerText, fichero.SelectSingleNode("/localizacion/en/ventanaconexion/errorServidor2").InnerText); } } }