private void ComboConexiones_SelectedIndexChanged(object sender, EventArgs e) { if (ComboConexiones.SelectedIndex == -1) { BAnalizar.Enabled = false; return; } BAnalizar.Enabled = true; //----------------------------------------- string archivo = DirConexiones + "\\" + ComboGrupos.Items[ComboGrupos.SelectedIndex].ToString() + "\\" + ComboConexiones.Items[ComboConexiones.SelectedIndex].ToString(); if (!System.IO.File.Exists(archivo)) { MessageBox.Show("No se encontro la conexion"); return; } AdministrarConexiones.CInstanciadorDB IDB = new AdministrarConexiones.CInstanciadorDB(); DB2 = IDB.DameInstancia(DirConexiones + "\\" + ComboGrupos.Items[ComboGrupos.SelectedIndex].ToString(), ComboConexiones.Items[ComboConexiones.SelectedIndex].ToString()); try { DB2.PruebaConexion(); } catch (System.Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message); ComboConexiones.SelectedIndex = -1; return; } this.Text = DB2.ConnectionString; }
private void ComboConexionesDestino_SelectedIndexChanged(object sender, EventArgs e) { if (ComboConexionesDestino.SelectedIndex == -1) { return; } string archivo = DirConexiones + "\\" + ComboGrupos2.Items[ComboGrupos2.SelectedIndex].ToString() + "\\" + ComboConexionesDestino.Items[ComboConexionesDestino.SelectedIndex].ToString(); if (!System.IO.File.Exists(archivo)) { MessageBox.Show("No se encontro la conexion"); return; } AdministrarConexiones.CInstanciadorDB IDB = new AdministrarConexiones.CInstanciadorDB(); DBDestino = IDB.DameInstancia(DirConexiones + "\\" + ComboGrupos2.Items[ComboGrupos2.SelectedIndex].ToString(), ComboConexionesDestino.Items[ComboConexionesDestino.SelectedIndex].ToString()); try { DBDestino.PruebaConexion(); } catch (System.Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message); ComboConexionesDestino.SelectedIndex = -1; return; } }