惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
U
Unit 42
Google DeepMind News
Google DeepMind News
博客园 - 司徒正美
Y
Y Combinator Blog
F
Fortinet All Blogs
云风的 BLOG
云风的 BLOG
T
Tailwind CSS Blog
G
Google Developers Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
罗磊的独立博客
D
DataBreaches.Net
T
The Blog of Author Tim Ferriss
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
MyScale Blog
MyScale Blog
N
Netflix TechBlog - Medium
Microsoft Security Blog
Microsoft Security Blog
GbyAI
GbyAI
P
Proofpoint News Feed
Jina AI
Jina AI
B
Blog RSS Feed
腾讯CDC
阮一峰的网络日志
阮一峰的网络日志
D
Docker

博客园 - 点点滴滴

C#操作IIS的代码 恢复误删数据(SQL Server 2000)--Log Explorer 如何让ClickOnce进行手动更新(含代码) - 点点滴滴 - 博客园 BackgroundWorker 组件 获取VS.NET 自带的数据库连接对话框的数据库连接 Application.DoEvent() 在C#使用XML注释 用IDisposable接口释放.NET资源 正确的重载operator 很好的debug有理由不用吗 C#调用API访问其它进程 抽象 虚方法 接口 的区别 ASP.NET AJAX 路线图 ASP.NET AJAX 概述 安装ASP.NET AJAX Visitor Template Method Strategy State
搜索一个局域网中所有的SQL Server服务器
点点滴滴 · 2006-12-17 · via 博客园 - 点点滴滴

引用Microsoft SQLDMO Object Library(SQLDMO.DLL)

 1using System;
 2using System.Collections.Generic;
 3using System.Text;
 4using Microsoft.SqlServer.Server;
 5
 6namespace ConsoleApplication1
 7{
 8    class Api
 9    {
10        /// <summary>
11        /// 列出局域网中的所有数据库
12        /// </summary>

13        public void LoadAllSqlServer()
14        {
15            SQLDMO.ApplicationClass app = new SQLDMO.ApplicationClass();
16            SQLDMO.NameList nameList =             app.ListAvailableSQLServers();            
17            for (int i = 0; i < nameList.Count; i++)
18            {
19                if (nameList.Item(i).ToString().Length != 0)
20                {
21                    Console.WriteLine(nameList.Item(i).ToString());
22                }

23            }

24        }

25        /// <summary>
26        /// 列出指定服务器的数据库列表
27        /// </summary>
28        /// <param name="serverName">服务器</param>
29        /// <param name="LoginName">登陆用户</param>
30        /// <param name="passWord">登陆密码</param>

31        public void LoadALlDatabase(string serverName, string LoginName, string passWord)
32        {
33            SQLDMO.SQLServerClass sqlServer = new SQLDMO.SQLServerClass();
34            try
35            {
36                sqlServer.Connect(serverName, LoginName, passWord);
37                for (int i = 0; i < sqlServer.Databases.Count; i++)
38                {
39                    Console.WriteLine(sqlServer.Databases.Item(i).Name);
40                }

41            }

42            catch
43            {
44                Console.WriteLine("Error");
45            }

46            
47        }

48
49    }

50}