我是按网上的文章写的dll和存储过程,在存储过程中调用外部的动态连接库,http://dev.21tx.com/2005/05/07/11174.html。无法在库 C:\Program Files\Microsoft SQL Server\MSSQL\Binn\storeproc.dll 中找到函数 SetFileName。原因: 127(找不到指定的程序。)。请指点迷津!!!!!!!!!!!!

解决方案 »

  1.   

    exec sp_addextendedproc 'SetFileName', 'storeproc.dll' --声明函数 
    exec sp_addextendedproc 'addLine', 'storeproc.dll'
      

  2.   

    dll 复制到 C:\Program Files\Microsoft SQL Server\MSSQL\Binn\storeproc 下没有
      

  3.   

    已经copy进去C:\Program Files\Microsoft SQL Server\MSSQL\Binn\storeproc.dll
      

  4.   

    我确定sqlserver已经在用了,因为我删除时候提示在使用,停掉sqlserver才能删除dll
      

  5.   


    说明:这里的DLL是用COM写的,需要注册一下下面是调用的例子代码:存储过程说明:
    在SQL中调用动态链接库中的函数
    代码示例:
    ALTER PROCEDURE dbo.StoredProcedure2
    /*
    (
    @parameter1 datatype = default value,
    @parameter2 datatype OUTPUT
    )
    */
    AS
    /* SET NOCOUNT ON */
    declare @ErrorCode int           --//错误码
    declare @object    int            --//令牌
    declare @Source  varchar (255)     -- //返回错误信息
    declare @Dest    varchar (255)
    declare @dk_str varchar(255)           --传入的参数
    select @ErrorCode =@@Error
    if @ErrorCode = 0
       exec @ErrorCode = sp_OACreate 'DK_DLL.Hourse',@Object Output
    if @ErrorCode =0
    select @dk_str ='d:\\test.txt'          --为参数赋值
    exec @ErrorCode=sp_OAMethod @Object ,'OutFile' ,NULL,@dk_str/*@ourValue Output*/
                                                         --(这里一定要有@符号,文档有错误)
      if @ErrorCode<>0
       exec sp_OAGetErrorInfo @Object ,@Source output,@Dest output
       set @Dest ='Error ('+Convert (varchar ,@ErrorCode)
                           +','+@Source + '):'+@Dest
                           Raiserror (@Dest,16,1)
    exec sp_OADestroy @Object
    /*sp_OAMethod 的用法: ObjPointer int IN, MethodName varchar IN [, @returnval <any> OUT [, additional IN, OUT, or BOTH params]]
     
    */
    RETURN