Example #1
0
        public static List <SqlDatabaseSettings> GetSQLDatabasesSettings(string pDatabaseServerName, string pDatabaseLoginName, string pDatabasePassword, bool pintegrated)
        {
            SqlConnection connection = ConnectionManager.GeneralSqlConnection;

            try
            {
                connection.Open();
                SQLInfoEnumerator sie = new SQLInfoEnumerator
                {
                    SQLServer          = pDatabaseServerName,
                    Username           = pDatabaseLoginName,
                    Password           = pDatabasePassword,
                    IntegratedSecurity = pintegrated
                };

                List <SqlDatabaseSettings> list = new List <SqlDatabaseSettings>();
                foreach (string database in sie.EnumerateSQLServersDatabases())
                {
                    SqlDatabaseSettings sqlDatabase = _GetDatabaseInfos(database, connection);
                    if (sqlDatabase == null)
                    {
                        continue;
                    }

                    list.Add(sqlDatabase);
                }

                connection.Close();
                return(list);
            }
            catch (Exception ex)
            {
                connection.Close();
                throw ex;
            }
        }
Example #2
0
        public static List<SqlDatabaseSettings> GetSQLDatabasesSettings(string pDatabaseServerName, string pDatabaseLoginName, string pDatabasePassword, bool pintegrated)
        {
            SqlConnection connection = ConnectionManager.GeneralSqlConnection;
            try
            {
                connection.Open();
                SQLInfoEnumerator sie = new SQLInfoEnumerator
                {
                    SQLServer = pDatabaseServerName,
                    Username = pDatabaseLoginName,
                    Password = pDatabasePassword,
                    IntegratedSecurity = pintegrated
                };

                List<SqlDatabaseSettings> list = new List<SqlDatabaseSettings>();
                foreach (string database in sie.EnumerateSQLServersDatabases())
                {
                    SqlDatabaseSettings sqlDatabase = _GetDatabaseInfos(database, connection);
                    if (sqlDatabase == null) continue;

                    list.Add(sqlDatabase);
                }

                connection.Close();
                return list;
            }
            catch (Exception ex)
            {
                connection.Close();
                throw ex;
            }
        }