取得局域网内的所有数据库服务器列表
来源:互联网 发布:最好的安卓编程语言 编辑:程序博客网 时间:2024/04/29 10:22
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using SQLDMO;
namespace TestSQLDMO
{
?????? ///
?????? /// Form1 的摘要说明。
?????? ///
?????? public class Form1 : System.Windows.Forms.Form
?????? {
????????????? private System.Windows.Forms.Button button1;
????????????? ///
????????????? /// 必需的设计器变量。
????????????? ///
????????????? private System.ComponentModel.Container components = null;
????????????? public Form1()
????????????? {
???????????????????? //
???????????????????? // Windows 窗体设计器支持所必需的
???????????????????? //
???????????????????? InitializeComponent();
???????????????????? //
???????????????????? // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
???????????????????? //
????????????? }
????????????? ///
????????????? /// 清理所有正在使用的资源。
????????????? ///
????????????? protected override void Dispose( bool disposing )
????????????? {
???????????????????? if( disposing )
???????????????????? {
??????????????????????????? if (components != null)
??????????????????????????? {
?????????????????????????????????? components.Dispose();
??????????????????????????? }
???????????????????? }
???????????????????? base.Dispose( disposing );
????????????? }
????????????? #region Windows Form Designer generated code
?????? ?????? ///
????????????? /// 设计器支持所需的方法 - 不要使用代码编辑器修改
????????????? /// 此方法的内容。
????????????? ///
????????????? private void InitializeComponent()
????????????? {
???????????????????? this.button1 = new System.Windows.Forms.Button();
???????????????????? this.SuspendLayout();
???????????????????? //
???????????????????? // button1
???????????????????? //
???????????????????? this.button1.Location = new System.Drawing.Point(104, 192);
???????????????????? this.button1.Name = "button1";
???????????????????? this.button1.TabIndex = 0;
???????????????????? this.button1.Text = "button1";
???????????????????? this.button1.Click += new System.EventHandler(this.button1_Click);
???????????????????? //
???????????????????? // Form1
???????????????????? //
???????????????????? this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
???????????????????? this.ClientSize = new System.Drawing.Size(292, 266);
???????????????????? this.Controls.AddRange(new System.Windows.Forms.Control[] {
????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? ? this.button1});
???????????????????? this.Name = "Form1";
???????????????????? this.Text = "Form1";
???????????????????? this.ResumeLayout(false);
????????????? }
????????????? #endregion
????????????? ///
????????????? /// 应用程序的主入口点。
????????????? ///
????????????? [STAThread]
????????????? static void
????????????? {
???????????????????? System.Windows.Forms.Application.Run(new Form1());
????????????? }
????????????? private void button1_Click(object sender, System.EventArgs e)
????????????? {
???????????????????? SQLDMO.ApplicationClass sqlApp = new SQLDMO.ApplicationClass();
???????????????????? SQLDMO.NameList nameList;
???????????????????? int i = 0;
???????????????????? nameList = sqlApp.ListAvailableSQLServers();
???????????????????? for(i=1;i
???????????????????? {
??????????????????????????? MessageBox.Show(nameList.Item(i).ToString());
???????????????????? }
????????????? }
?????? }
}
获得SQLServer中所有的数据库中和表
????????????? private void Button1_Click(object sender, System.EventArgs e)
????????????? {
???????????????????? SQLDMO.Application sqlApp = new SQLDMO.ApplicationClass();
???????????????????? SQLDMO.SQLServer server = new SQLDMO.SQLServerClass();
???????????????????? server.Connect(txtServer.Text.Trim(),txtUser.Text.Trim(),txtPass.Text.Trim());
???????????????????? string strTables="";
???????????????????? string strRow="";
???????????????????? strRow+=("####?? "+ server.Databases.Count +"? #######");
???????????????????? Response.Write(strRow);
???????????????????? for(int i=1 ; i< server.Databases.Count;i++)
???????????????????? {
??????????????????????????? strRow +=("========?? "+i+"?? =========="+server.Databases.Item(i,"sa").Tables.Count+"=============");
??????????????????????????? strRow +=(server.Databases.ItemByID(i).Name );
???????????????????????????
??????????????????????????? Response.Write(strRow);
//????????????????????????? lstName.Items.Add(server.Databases.ItemByID(i).Status? );
??????????????????????????? for(int j=1;j
??????????????????????????? {
?????????????????????????????????? strRow = "";
?????????????????????????????????? SQLDMO.Tables tables = server.Databases.Item(i,"sa").Tables;
?????????????????????????????????? strTables +=tables.Item(j,"dbo").ID +"------"+tables.Item(j,"dbo").Name +"------"+tables.Item(j,"dbo").Owner? +"------"+tables.Item(j,"dbo").Application.Name?? ;
?????????????????????????????????? strTables+="&&&? "+j+" &&&";
?????????????????????????????????? strRow +=(strTables);
?????????????????????????????????? Response.Write(strRow);
??????????????????????????? }
???????????????????????????
??????????????????????????? strRow =("****************************");
??????????????????????????? Response.Write(strRow);
???????????????????????????
????????????? ?????? }
要添加引用sqldmo.dll
你安装了SqlServer2000 就有了,在添加引用中找它
最好使用SQL Server 2000的SP3的sqldmo.dll
- 取得局域网内的所有数据库服务器列表
- 获取局域网内所有可用的SQL Server服务器列表
- C#获取局域网内所有数据库服务器
- 获取局域网内所有的数据库实例
- 取得局域网里所有的SQL Server服务器
- C#获取局域网内sql server数据库服务器列表
- vb搜索局域网内所有SQL Server服务器和指定SQL Server服务器上的所有数据库
- Delphi遍历局域网内所有的Sql Server服务器
- C#列出局域网内所有的SQL SERVER服务器
- 枚举局域网内所有的 SQL Server 服务器实例名
- 获取服务器的所有数据库名称列表
- 取得页面内的所有链接
- 查看局域网内所有的IP
- 解析c#得到局域网内所有sqlserver数据库实例
- 取得网络中SQL的服务器列表
- 无法访问局域网内IIS服务器的解决办法
- 无法访问局域网内IIS服务器的解决办法
- 局域网内服务器入侵的防范措施
- oracle中的共享服务器和专用服务器
- 今天开通了Blog。
- 鼠标移动时行变色并可以点击行时选中行
- 操作Word的权限问题
- 关于强名称
- 取得局域网内的所有数据库服务器列表
- 获取CPU的ID码
- 访问局域网资源
- 用xmlhttp读取webservice提供的dataset并写入table
- 停止或开启系统服务-续(远程调用)
- 使文件下载的自定义连接支持 FlashGet 的断点续传多线程链接下载! C#/ASP.Net 实现!
- 基于面向对象技术的异构系统整合
- 需求清单20040802--界面设计
- MFC Discovery 1