请大哥帮忙一下,我写的从自己的机器(192.168.1.1)上从1434端口广播(192.168.1.255)了这个UDP包,然后,整个局域网中的SQL Server服务器都开始响应这个UDP数据包,所有这些都是明文传输的,我们可以很容易探测一个IP地址的1434端口,获得该IP地址上运行的SQL Server的相关信息。
速度超慢!!!!

解决方案 »

  1.   

    #region 取得区域内的服务器名
    private void GetSQlServer()
    {
    SQLDMO.NameList NameList; 
    SQLDMO.ApplicationClass appsql=new SQLDMO.ApplicationClass();
    int Index;            
    try
    {
    cboServerName.Items.Clear();
    NameList=appsql.ListAvailableSQLServers();

    if(NameList.Count>0)
    {
    for(Index=1;Index<=NameList.Count;Index++)
    {
    if(NameList.Item(Index).Equals("(local)"))
    {
    cboServerName.Items.Add(Environment.MachineName);
    }
    else
    {
    cboServerName.Items.Add(NameList.Item(Index).ToString());
    }
    }
    }

    }
    catch(Exception ex)
    {
    appsql=null;
    NameList=null;
    MessageBox.Show(ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
    }
    finally
    {
    appsql=null;
    NameList=null;
    }
    }
    #endregion要引用SQLDMO.dll文件
      

  2.   

    http://www.cnblogs.com/gwazy/archive/2005/03/02/111127.html看看吧.
      

  3.   

    SQLDMO.Application sqlApp = new SQLDMO.ApplicationClass(); 
    SQLDMO.NameList sqlServers = sqlApp.ListAvailableSQLServers(); 
    for(int i=0;i<sqlServers.Count;i++) 

    object srv = sqlServers.Item(i + 1); 
    if(srv != null) 

    cboServers.Items.Add(srv);                         


    if(cboServers.Items.Count > 0) 
    cboServers.SelectedIndex = 0; 
    else 
    cboServers.Text = "<No available SQL Servers>";
    关键要添加对sqldmo.dll的引用