Пример #1
0
        /// <summary>
        /// 返回数据库列表
        /// </summary>
        /// <returns></returns>
        public ArrayList GetDbList()
        {
            ArrayList alDbs = new ArrayList();

            SQLDMO.Application sqlApp = new SQLDMO.ApplicationClass();
            SQLDMO.SQLServer   svr    = new SQLDMO.SQLServerClass();
            try
            {
                svr.Connect(ServerName, UserName, Password);
                foreach (SQLDMO.Database db in svr.Databases)
                {
                    if (db.Name != null)
                    {
                        alDbs.Add(db.Name);
                    }
                }
            }
            catch (Exception e)
            {
                throw (new Exception("连接数据库出错:" + e.Message));
            }
            finally
            {
                svr.Close();
                sqlApp.Quit();
            }
            return(alDbs);
        }
Пример #2
0
 /// <summary>
 /// �������ݿ��б�
 /// </summary>
 /// <returns></returns>
 public ArrayList GetDbList()
 {
     ArrayList alDbs = new ArrayList();
     SQLDMO.Application sqlApp = new SQLDMO.ApplicationClass();
     SQLDMO.SQLServer svr = new SQLDMO.SQLServerClass();
     try
     {
         svr.Connect(ServerName, UserName, Password);
         foreach (SQLDMO.Database db in svr.Databases)
         {
             if (db.Name != null)
                 alDbs.Add(db.Name);
         }
     }
     catch (Exception e)
     {
         throw (new Exception("�������ݿ�����" + e.Message));
     }
     finally
     {
         svr.Close();
         sqlApp.Quit();
     }
     return alDbs;
 }