我用Delphi7制作了一个数据库程序里面用到了SQLDMO,用来得到局域网中所有的SQLServer服务器列表,并添加到ComboBox中,想在不安装SQLServer(2000)的机子上使用,请问用InstallSheld打包时,要添加哪些文件,这些文件怎样组织,要注册哪些文件?不知哪为大侠能够帮忙解决?

解决方案 »

  1.   

    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\Binn\
    Resources\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\Tools\
    Devtools\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\Tools\
    Devtools\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\Tools\
    Devtools\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
      

  2.   

    DebugXP(NULL)
      先说声谢谢你,这段文章我有,但这些文件怎样组织,Sqldmo.rll 是用哪个文件夹(1033,2052)还有这些文件复制到什么文件夹下(System32 还是别的文件夹)我安装的SQLServer2000里没有Sqldmo.h 、Sqldmoid.h文件,怎么办?麻烦你能不能说的再清楚一些?
      

  3.   

    以下是我在网上搜索到的一些资料,但是我都没有试成功,哪位高手能够指条路!问:我想测试一个从Microsoft Visual Basic V 6.0到SQL Server的连接。我开始想通过SQL-DMO 的VerifyConnection属性进行测试,但是没有取得成功。列表1列出了我所使用的代码。这些代码有什么错误吗? 列表1:读者的代码,通过SQL-DMO的VerifyConnection属性对SQL Server连接进行测试的尝试没有取得成功 Public oSQLServer As New SQLDMO.SQLServer
    oSQLServer.LoginTimeout = 10 
    oSQLServer.Connect StrServer, strUser, StrPwd 
    oSQLServer.StatusInfoRefetchInterval 
    (SQLDMOStatInfo_AutoVerifyConnection) = 10
        CnOk = oSQLServer.IsLogin("sa") 
    If Err.Number <> 0 Then 
        oSQLServer.ReConnect
    End If 
    If oSQLServer.VerifyConnection(2) Then
           'ok 
    Else
           'not ok
    End if
    答: 如果你需要了解从Visual Basic到SQL Server的连接是否能够正常工作,你可以使用PingSQLServerVersion 方法,如下面的列表2所示。同你所写的脚本相比,这些代码的运行速度很快而且耗费的资源也很少。此外,VerifyConnection 仅仅能验证已经建立的连接。在你对VerifyConnection的调用中,参数应该是 boolean 而不是int。还有,您的如下代码: oSQLServer.StatusInfoRefetchInterval 
    (SQLDMOStatInfo_AutoVerifyConnection) = 10 
    会降低系统性能,因为你在断定连接状态时使用了10秒钟的间隔周期而不是30秒。 列表2:通过SQL-DMO的PingSQLServerVersion方法测试SQL Server连接的代码。 On Error Resume Next Dim oSQLServer As SQLDMO.SQLServer
    Dim sqlversion As SQLDMO_SQL_VER
    Set oSQLServer = New SQLDMO.SQLServer
    sqlversion = oSQLServer.PingSQLServerVersion("SERVERNAME")
         If Err.Number <> 0 Or sqlversion = SQLDMOSQLVer_Unknown Then
         ' You have a problem.
    End If
    Set oSQLServer = Nothing
    问:我想测试一个从Microsoft Visual Basic V 6.0到SQL Server的连接。我开始想通过SQL-DMO 的VerifyConnection属性进行测试,但是没有取得成功。列表1列出了我所使用的代码。这些代码有什么错误吗? 列表1:读者的代码,通过SQL-DMO的VerifyConnection属性对SQL Server连接进行测试的尝试没有取得成功 Public oSQLServer As New SQLDMO.SQLServer
    oSQLServer.LoginTimeout = 10 
    oSQLServer.Connect StrServer, strUser, StrPwd 
    oSQLServer.StatusInfoRefetchInterval 
    (SQLDMOStatInfo_AutoVerifyConnection) = 10
        CnOk = oSQLServer.IsLogin("sa") 
    If Err.Number <> 0 Then 
        oSQLServer.ReConnect
    End If 
    If oSQLServer.VerifyConnection(2) Then
           'ok 
    Else
           'not ok
    End if
      

  4.   


    我在调用SQL-DMO对象的时候
    他会把File Program之类的带空格的文件视作相对路径,
    例如:本来传入的是C:\File Program\DB.bak
    他实际处理却当作D:\File Program\MSServer\SQL\Program\DB.bak
    实际上空格之后的路径被它当作相对路径了,请问怎么处理
    function TdbmSQLDMO.BackupDB(DBName, BackupFile: string): Boolean;
    var SQLBackup: _Backup;
    begin
      Result := True;
      try
      //工厂创建
        SQLBackup := coBackup.Create;
      except
        TdbmCommon.MsgBox('备份对象无法创建,请检查是否安装SQLSERVER或MSDE引擎!');
        Result := false;
        Exit;
      end;  try
        with SQLBackup do
        begin
          try
        //问题::无法保存到MS目录
            Database := DBName;
            Files := BackupFile;    //这里传入的是C:\File Program\DB.bak
                       //他实际处理却当作D:\File Program\MSServer\SQL\Program\DB.bak
          //重写还是追加
        //  if BackupMode.bOverWrite then
            Initialize := true;
            SQLBackup(FSQLServer);
          except
            on E: Exception do
            begin
              TdbmCommon.MsgBox(E.Message);
              Result := false;
            end;
          end;
        end;
      finally
        BreakConnection;
      end;
    end;把SQLSERVER的MSDE取出来打包就可以了答: 如果你需要了解从Visual Basic到SQL Server的连接是否能够正常工作,你可以使用PingSQLServerVersion 方法,如下面的列表2所示。同你所写的脚本相比,这些代码的运行速度很快而且耗费的资源也很少。此外,VerifyConnection 仅仅能验证已经建立的连接。在你对VerifyConnection的调用中,参数应该是 boolean 而不是int。还有,您的如下代码: oSQLServer.StatusInfoRefetchInterval 
    (SQLDMOStatInfo_AutoVerifyConnection) = 10 
    会降低系统性能,因为你在断定连接状态时使用了10秒钟的间隔周期而不是30秒。 列表2:通过SQL-DMO的PingSQLServerVersion方法测试SQL Server连接的代码。 On Error Resume Next Dim oSQLServer As SQLDMO.SQLServer
    Dim sqlversion As SQLDMO_SQL_VER
    Set oSQLServer = New SQLDMO.SQLServer
    sqlversion = oSQLServer.PingSQLServerVersion("SERVERNAME")
         If Err.Number <> 0 Or sqlversion = SQLDMOSQLVer_Unknown Then
         ' You have a problem.
    End If
    Set oSQLServer = Nothing
    安装 SQL-DMO
    全部的必需的 SQL-DMO 组件 是 安装 as part of an instance of Microsoft&reg; SQL Server&#8482; 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&reg;, 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\Binn\
    Resources\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\Tools\
    Devtools\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\Tools\
    Devtools\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\Tools\
    Devtools\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
    请察看
    http://support.microsoft.com/default.aspx?scid=kb;EN-US;q248241
    只要你按它说的做就行了,我已经试验通过。
    你把sqldmo发布一下就可以了。
    --得到服务器名及ip地址,考虑了实例的问题:declare @sname sysname,@ip varchar(15),@sql varchar(1000)--得到计算机名
    set @sname=case when charindex('\',@@servername)=0 then @@servername
    else left(@@servername,charindex('\',@@servername)-1) end--得到ip地址
    create table #ip(a varchar(200))
    set @sql='ping '+@sname+' -a -n 1 -l 1'
    insert into #ip exec master..xp_cmdshell @sqlselect @ip=left(a,patindex('%:%',a)-1) from(
    select a=substring(a,patindex('Ping statistics for %:%',a)+20,20)
    from #ip where a like 'Ping statistics for %:%') a--显示结果
    select 计算机名=@sname,ip地址=@ipgo
    drop table #ip
    master..xp_cmdshell 'osql.exe -L'
    -- 得到局域网内所有SQL服务器名字与ip地址的存储过程:create proc send_message as begin
      create table #tspid(
    spid int null,
    ecid int null,
    status varchar(200) null,
    loginname varchar(200) null,
    hostname varchar(200) null,
    blk bit null,
    dbname varchar(200) null,
    cmd varchar(200)
      )insert into #tspid(spid,ecid,status,loginname,hostname,blk,dbname,cmd) exec sp_who create table #userip(id int identity,hostname varchar(200),txt varchar(8000))declare @cmdStr varchar(100), @hostName varchar(30), @userip varchar(20), @sendstr varchar(100)declare tspid cursor for select hostname from #tspid where spid>50
    open tspid   fetch next from tspid into @hostname
       WHILE @@FETCH_STATUS = 0
       begin
    create table #table (id int identity,txt varchar(8000))
    select @cmdStr='ping '+@hostName
    insert #table(txt) exec master..xp_cmdshell @cmdStr
    insert #userip select @hostname,substring(txt,charindex('[',txt)+1,charindex(']',txt)-charindex('[',txt)-1) from #table where id=2
    drop table #table
       fetch next from tspid into @hostname
       end select * from #userip
      drop table #tspid ,#userip
    endgo--调用:
    exec send_message
    需要先注册sqldmo.dll,如果注册了都还是不行,就安装MDAC,到www.microsoft.com\data下载。
    我想检测出网内所有的SQLSERVER服务,即检测出哪台机子上装有SQLSERVER服务及数据库名称!原理:得到IP.然后再PING 1433端口,如通一般就是SQLSERVER的服务器了.
    ……,只能在注册了SQLDMO.DLL的机器上作用,否则出现“字符串类未注册”的提示。也就是说,必须将有SQL Server至少应该有MSDE才行,非得安装这些东西吗?有没有更好的办法,比如将SQLDMO.DLL打包编译进去……,请各位朋友指点。
      

  5.   

    只能在注册了SQLDMO.DLL的机器上作用,否则出现“字符串类未注册”的提示。也就是说,必须将有SQL Server至少应该有MSDE才行,非得安装这些东西吗?有没有更好的办法,比如将SQLDMO.DLL打包编译进去……,请各位朋友指点。