Exemple #1
0
 public OutputLog(LogException le)
 {
     this.le = le;
 }
        /// <summary>
        /// Populate the combobox with the list of databases existed in a server name
        /// </summary>
        void PopulateDatabaseName()
        {
            try
            {
                databaseNames.Clear(); //make sure to clear the list of databases
                cbDatabaseName.DataSource = null; //clear the combobox
                ConnectServer(); //make connection to new server name if so
            }
            catch (SqlException ex) //if an exception occurs
            {
                LogException le = new LogException(this.GetType().Name,
                                                    "Catching SqlException", ex,
                                                    "PopulateDatabaseName()", DateTime.Now);
                OutputLog ol = new OutputLog(le);
                ol.WriteLog();
                databases = null; //destroy the DataTable object
                MessageBox.Show("Server name does not exit or access denied"); //inform the user
                cbDatabaseName.DataSource = null; //set the combobox to null
                cbDatabaseName.DataSource = databaseEmpty; //hack: displaying a member saying it is loading table
            }
            if (databases != null)
            {
                foreach (DataRow row in databases.Rows)
                {
                    string databaseName = row.Field<string>("database_name");
                    databaseNames.Add(databaseName);
                }

            }
            cbDatabaseName.DataSource = databaseNames;
        }
Exemple #3
0
 public OutputLog(LogException le)
 {
     this.le = le;
 }