利用ODBC工具建立一个SQL的系统DSN时配置第一页有一个选项:您想连接到哪一个SQL Server?
下面是一个组合框,下拉时会出现可以访问到的所有SQL服务器?我想问样达到这个效果,即如何获得所有有访问的SQL Server列表?

解决方案 »

  1.   

    http://www.codeproject.com/database/sqlsrvenumerator.asp
      

  2.   

    #import Sqldmo.dll
    SQL-DMO::ApplicationPtr->ListAvailableSQLServers( ); // as NameList
      

  3.   

    I must  this topic to study hard
      

  4.   

    搂主:
    二楼确实可用
    但我还建议你用微软的SQL-DMO组件,他的代码更简单根直观,实际代码和我贴的差不多,
    SQL-DMO::ApplicationPtr->ListAvailableSQLServers的返回值为一安全数组的变体形由于我现在手头的机器上没装SQL Server,所以给不出Sqldmo.dll的详细位置分,无所谓了
      

  5.   

    SQL-DMO Files
    The following SQL-DMO files are included with the SQL Server 32-bit client tools for Windows 95 and Windows NT, which you must install to use SQL-DMO.In C:\SQL60\DLL  
    File Description   
    SQLOLE.HLP Help file containing reference information about SQL-DMO objects, properties, methods, lists, and collections. 
    SQLOLE.REG SQL-DMO Registry file. 
    SQLOLE32.DLL SQL-DMO in-process server and COM custom component. 
    SQLOLE32.TLB SQL-DMO type library, usually used by OLE Automation controllers like Visual Basic. In C:\SQL60\INSTALL  
    File Description   
    SQLOLE42.SQL Transact-SQL script to create SQL-DMO stored procedures for SQL Server 4.21 servers. You must install these on a SQL Server 4.21 server before SQL-DMO objects can connect to that server. 
    SQLOLE60.SQL Transact-SQL script to create SQL-DMO stored procedures for SQL Server 6.0 servers. These are already installed by SQL Server 6.0. In C:\SQL60\SQLOLE\INCLUDE  
    File Description   
    SQLOLE.H Header file for C++ programs containing function prototypes for SQL-DMO objects, properties, methods, lists, and collections. 
    SQLOLEID.H Header file for C++ programs containing class IDs and interface IDs for SQL-DMO. In C:\SQL60\SQLOLE\SAMPLES  
    File Description   
    README.TXT Summary of sample programs available in each directory.  
      

  6.   

    SQL-DMO  
    Installing SQL-DMO
    All required SQL-DMO components are installed as part of an instance of Microsoft® SQL Server™ server or client. SQL-DMO is implemented in a single dynamic-link library (DLL). You may develop SQL-DMO applications on either a client or a server. When using an OLE Automation controller as a development platform, such as Microsoft Visual Basic®, no additional files are required. Application development using C or C++ requires the SQL-DMO header files.SQL-DMO sample applications, providing additional reference material for SQL-DMO application development, are included with SQL Server.Directory File Description 
    C:\Program Files\Microsoft SQL Server\80\Tools\Binn Sqldmo.dll DLL implementing SQL-DMO objects. 
    C:\Program Files\Microsoft SQL Server\80\Tools\Binn Sqldmo80.hlp SQL-DMO help file used within the development environment to provide context sensitive help about SQL-DMO objects, properties and methods. 
    C:\Program Files\Microsoft SQL Server\80\Tools\BinnResources\xxxx Sqldmo.rll Localized resource file. The resource directory varies based on the national language of the instance of SQL Server client or server. For example, the directory 1033 is a decimal representation of the language identifier 0X0409, indicating English, U.S. 
    C:\Program Files\Microsoft SQL Server\80\ToolsDevtools\Include Sqldmo.h C/C++ header file containing SQL-DMO member function prototypes, enumerated data types, and macros. 
    C:\Program Files\Microsoft SQL Server\80\ToolsDevtools\Include Sqldmoid.h C/C++ header file containing SQL-DMO interface and class identifiers. 
    \Program Files\Microsoft SQL Server\MSSQL\Install Sqldmo.sql Transact-SQL script implementing stored procedures that support SQL-DMO. Available on SQL Server server-instance only. 
    C:\Program Files\Microsoft SQL Server\80\ToolsDevtools\Samples\Sqldmo ALL Sample applications illustrating SQL-DMO use. 
    To register the SQL-DMO components on a client computer From C:\Program Files\Microsoft SQL Server \80\Tools\Binn\Resources\<language> directory, execute: 
    \Program Files\Microsoft SQL Server \80\Tools\Binn\REGSVR32 SQLDMO.DLLFrom any directory, execute: 
    C:\Program Files\Microsoft SQL Server \80\Tools\Binn\REGSVR32.EXE C:\Program Files\Microsoft SQL Server \80\Tools\Binn\resources\1033\SQLDMO.RLL
    See AlsoOverview of Installing SQL Server 2000&copy;1988-2003 Microsoft Corporation. All Rights Reserved.