private void SetUI(CnnString cnn) { WindowsAutentificaction.Checked = cnn.WindowsAutentification; cmbDataBases.Text = cnn.InitialCatalog; cmbServer.Text = cnn.DataSource; if (cnn.WindowsAutentification) { txtUserName.Text = string.Empty; txtPassword.Text = string.Empty; txtUserName.Enabled = false; txtPassword.Enabled = false; lblUserName.ForeColor = System.Drawing.Color.Black; lblPassword.ForeColor = System.Drawing.Color.Black; } else { txtUserName.Text = cnn.User; txtPassword.Text = cnn.Password; txtUserName.Enabled = true; txtPassword.Enabled = true; lblUserName.ForeColor = System.Drawing.Color.DimGray; lblPassword.ForeColor = System.Drawing.Color.DimGray; } if (string.IsNullOrEmpty(cnn.DataSource) || string.IsNullOrEmpty(cnn.InitialCatalog)) { return; } txtCnnString.Text = cnn.ToString(); }
/// <summary> /// Carga las bses de datos del server /// </summary> /// <param name="pCnnString"></param> void FillDatabaseCombo(CnnString pCnnString) { if (onInitServerCollection) { return; } SqlConnection sqlConnection = new SqlConnection(pCnnString.ToString()); ServerConnection serverConnection = new ServerConnection(sqlConnection); try { _Server = new Server(serverConnection); cmbDataBases.Items.Clear(); foreach (Database db in _Server.Databases) { cmbDataBases.Items.Add(db.Name); } cmbDataBases.SelectedIndex = 0; } catch (Exception ex) { MessageBox.Show(Fwk.CodeGenerator.HelperFunctions.GetAllMessageException(ex), Fwk.GuidPk.Properties.Resources.ProductTitle); } }
public bool Test() { _cnn = GetAuxiliarCnnString(); if (string.IsNullOrEmpty(_cnn.DataSource)) { MessageBox.Show("Ingrese servidor de SQL.-", Fwk.GuidPk.Properties.Resources.ProductTitle); cmbServer.Focus(); return(false); } if (string.IsNullOrEmpty(_cnn.InitialCatalog)) { MessageBox.Show("Seleccione o ingrese una base de datos.-", Fwk.GuidPk.Properties.Resources.ProductTitle); cmbDataBases.Focus(); return(false); } if (!_cnn.WindowsAutentification) { if (string.IsNullOrEmpty(_cnn.User)) { MessageBox.Show("Ingrese usuario.-", Fwk.GuidPk.Properties.Resources.ProductTitle); txtUserName.Focus(); return(false); } } SqlConnection sqlConnection = new SqlConnection(_cnn.ToString()); Microsoft.SqlServer.Management.Common.ServerConnection serverConnection = new Microsoft.SqlServer.Management.Common.ServerConnection(sqlConnection); try { _Server = new Server(serverConnection); //_Server.Databases[_cnn.InitialCatalog].Tables.Refresh(); ////iterate over all Databases //foreach (Database db in _Server.Databases) //{ MessageBox.Show("Coneccion exitosa.- a " + _Server.Information.Product.ToString(), Fwk.GuidPk.Properties.Resources.ProductTitle); //} } catch (Exception ex) { MessageBox.Show(Fwk.CodeGenerator.HelperFunctions.GetAllMessageException(ex), Fwk.GuidPk.Properties.Resources.ProductTitle); return(false); } return(true); }
private void btnTestConnection_Click(object sender, EventArgs e) { _cnn = GetAuxiliarCnnString(); if (string.IsNullOrEmpty(_cnn.DataSource)) { MessageBox.Show("Ingrese servidor de SQL.-", "Fwk wizard"); cmbServer.Focus(); return; } if (string.IsNullOrEmpty(_cnn.InitialCatalog)) { MessageBox.Show("Seleccione o ingrese una base de datos.-", "Fwk wizard"); cmbDataBases.Focus(); return; } if (!_cnn.WindowsAutentification) { if (string.IsNullOrEmpty(_cnn.User)) { MessageBox.Show("Ingrese usuario.-", "Fwk wizard"); txtUserName.Focus(); return; } } SqlConnection sqlConnection = new SqlConnection(_cnn.ToString()); Microsoft.SqlServer.Management.Common.ServerConnection serverConnection = new Microsoft.SqlServer.Management.Common.ServerConnection(sqlConnection); try { _Server = new Server(serverConnection); ////iterate over all Databases foreach (Database db in _Server.Databases) { MessageBox.Show("Coneccion exitosa.-", "Fwk wizard"); return; } } catch (Exception ex) { MessageBox.Show(HelperFunctions.GetAllMessageException(ex), "Fwk wizard"); } }
public void setIDictionaryService(CnnString cnn) { IDictionaryService dictionaryService = GetService(typeof(IDictionaryService)) as IDictionaryService; if (cnn == null) { dictionaryService.SetValue("ConnectionString", null); dictionaryService.SetValue("DatabaseName", null); } else { dictionaryService.SetValue("ConnectionString", cnn.ToString()); dictionaryService.SetValue("DatabaseName", cnn.InitialCatalog); } }
private void LoadTables(CnnString cnn) { SqlConnection sqlConnection = new SqlConnection(cnn.ToString()); ServerConnection serverConnection = new ServerConnection(sqlConnection); try { Server wServer = new Server(serverConnection); Database db = new Database(wServer, cnn.InitialCatalog); db.Views.Refresh(); _Views = db.Views; } catch (Exception ex) { MessageBox.Show(HelperFunctions.GetAllMessageException(ex)); } }
/// <summary> /// Carga las bses de datos del server /// </summary> /// <param name="pCnnString"></param> void FillDatabaseCombo(CnnString pCnnString) { if (onInitServerCollection) return; SqlConnection sqlConnection = new SqlConnection(pCnnString.ToString()); ServerConnection serverConnection = new ServerConnection(sqlConnection); try { _Server = new Server(serverConnection); cmbDataBases.Items.Clear(); foreach (Database db in _Server.Databases) { cmbDataBases.Items.Add(db.Name); } cmbDataBases.SelectedIndex = 0; } catch (Exception ex) { MessageBox.Show(HelperFunctions.GetAllMessageException(ex)); } }
/// <summary> /// /// </summary> /// <param name="pCnnString"></param> /// <returns></returns> public static bool TestConnection(CnnString pCnnString) { using (SqlConnection wCnn = new SqlConnection(pCnnString.ToString())) { try { wCnn.Open(); wCnn.Close(); return true; } catch (Exception ex) { throw new DataBaseExeption(ex, pCnnString); } } }
private void btnTestConnection_Click(object sender, EventArgs e) { _cnn = GetAuxiliarCnnString(); if (string.IsNullOrEmpty(_cnn.DataSource)) { MessageBox.Show("Ingrese servidor de SQL.-", "Fwk wizard"); cmbServer.Focus(); return; } if (string.IsNullOrEmpty(_cnn.InitialCatalog)) { MessageBox.Show("Seleccione o ingrese una base de datos.-","Fwk wizard"); cmbDataBases.Focus(); return; } if (!_cnn.WindowsAutentification) { if (string.IsNullOrEmpty(_cnn.User)) { MessageBox.Show("Ingrese usuario.-", "Fwk wizard"); txtUserName.Focus(); return; } } SqlConnection sqlConnection = new SqlConnection(_cnn.ToString()); Microsoft.SqlServer.Management.Common.ServerConnection serverConnection = new Microsoft.SqlServer.Management.Common.ServerConnection(sqlConnection); try { _Server = new Server(serverConnection); ////iterate over all Databases foreach (Database db in _Server.Databases) { MessageBox.Show("Coneccion exitosa.-", "Fwk wizard"); return; } } catch (Exception ex) { MessageBox.Show(HelperFunctions.GetAllMessageException(ex), "Fwk wizard"); } }
public bool Test() { _cnn = GetAuxiliarCnnString(); if (string.IsNullOrEmpty(_cnn.DataSource)) { MessageBox.Show("Ingrese servidor de SQL.-", Fwk.GuidPk.Properties.Resources.ProductTitle); cmbServer.Focus(); return false; } if (string.IsNullOrEmpty(_cnn.InitialCatalog)) { MessageBox.Show("Seleccione o ingrese una base de datos.-", Fwk.GuidPk.Properties.Resources.ProductTitle); cmbDataBases.Focus(); return false; } if (!_cnn.WindowsAutentification) { if (string.IsNullOrEmpty(_cnn.User)) { MessageBox.Show("Ingrese usuario.-", Fwk.GuidPk.Properties.Resources.ProductTitle); txtUserName.Focus(); return false; } } SqlConnection sqlConnection = new SqlConnection(_cnn.ToString()); Microsoft.SqlServer.Management.Common.ServerConnection serverConnection = new Microsoft.SqlServer.Management.Common.ServerConnection(sqlConnection); try { _Server = new Server(serverConnection); //_Server.Databases[_cnn.InitialCatalog].Tables.Refresh(); ////iterate over all Databases //foreach (Database db in _Server.Databases) //{ MessageBox.Show("Coneccion exitosa.- a " + _Server.Information.Product.ToString(), Fwk.GuidPk.Properties.Resources.ProductTitle); //} } catch (Exception ex) { MessageBox.Show(Fwk.CodeGenerator.HelperFunctions.GetAllMessageException(ex), Fwk.GuidPk.Properties.Resources.ProductTitle); return false; } return true; }
private void SetUI(CnnString cnn) { WindowsAutentificaction.Checked = cnn.WindowsAutentification; cmbDataBases.Text = cnn.InitialCatalog; cmbServer.Text = cnn.DataSource; if (cnn.WindowsAutentification) { txtUserName.Text = string.Empty; txtPassword.Text = string.Empty; txtUserName.Enabled = false; txtPassword.Enabled = false; lblUserName.ForeColor = System.Drawing.Color.Black; lblPassword.ForeColor = System.Drawing.Color.Black; } else { txtUserName.Text = cnn.User; txtPassword.Text = cnn.Password; txtUserName.Enabled = true; txtPassword.Enabled = true; lblUserName.ForeColor = System.Drawing.Color.DimGray; lblPassword.ForeColor = System.Drawing.Color.DimGray; } if (string.IsNullOrEmpty(cnn.DataSource) || string.IsNullOrEmpty(cnn.InitialCatalog)) return; txtCnnString.Text = cnn.ToString(); }