Exemple #1
0
        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");
            }
        }
        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.Tables.Refresh();
                _Tables = db.Tables;
            }
            catch (Exception ex)
            {
                MessageBox.Show(HelperFunctions.GetAllMessageException(ex));
            }
        }
Exemple #3
0
        /// <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));
            }
        }
Exemple #4
0
        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");
            }
        }
        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.Tables.Refresh();
                _Tables = db.Tables;
            }
            catch (Exception ex)
            {
                MessageBox.Show(HelperFunctions.GetAllMessageException(ex));
            }
        }