private void SQLServerConectar() { ConnectSQLSever lxDlgCnx = new ConnectSQLSever(); lxDlgCnx.Cfg = Cfg; lxDlgCnx.ShowDialog(); if (lxDlgCnx.DialogResult.HasValue && lxDlgCnx.DialogResult.Value) { //OK Cursor = Cursors.Wait; SQLCnx = lxDlgCnx.SQLCnxInfo; try { IniCnx(); } catch (Exception ex) { MessageBoxResult r = MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } finally { Cursor = Cursors.Arrow; } } }
private void cmdOk_Click(object sender, RoutedEventArgs e) { SQLCnxInfo = _EsWinAut ? new SQLConexionInfo(txtServidor.Text, txtBasedeDatos.Text) : new SQLConexionInfo(txtServidor.Text, txtBasedeDatos.Text, txtUsr.Text, txtPsw.Password); DialogResult = true; }
private bool TestConection(SQLConexionInfo sqlCnxInfo) { using (SqlConnection lxCnx = new SqlConnection(sqlCnxInfo.ObtenerStringDeConexion())) { try { lxCnx.Open(); return(true); } catch { return(false); } } }
private void cmdTest_Click(object sender, RoutedEventArgs e) { this.Cursor = Cursors.Wait; SQLCnxInfo = _EsWinAut ? new SQLConexionInfo(txtServidor.Text, txtBasedeDatos.Text) : new SQLConexionInfo(txtServidor.Text, txtBasedeDatos.Text, txtUsr.Text, txtPsw.Password); if (TestConection(SQLCnxInfo) == true) { MessageBox.Show("Conexión Exitosa", "Prueba de Conexión", MessageBoxButton.OK, MessageBoxImage.Information); } else { MessageBox.Show("Error Conexión", "Prueba de Conexión", MessageBoxButton.OK, MessageBoxImage.Error); } this.Cursor = Cursors.Arrow; }