怎样在MS SQL注册一个"扩展存储过程"?

internetcsdn 2004-11-17 12:17:18
写有如下一个DLL(此DLL在DELPHI程序下调用通过)
------------------------------------------------------------------------
library W_AddAB;

{ Important note about DLL memory management: ShareMem must be the
first unit in your library's USES clause AND your project's (select
Project-View Source) USES clause if your DLL exports any procedures or
functions that pass strings as parameters or function results. This
applies to all strings passed to and from your DLL--even those that
are nested in records and classes. ShareMem is the interface unit to
the BORLNDMM.DLL shared memory manager, which must be deployed along
with your DLL. To avoid using BORLNDMM.DLL, pass string information
using PChar or ShortString parameters. }

uses
SysUtils,dialogs,
Classes;

{$R *.res}


function ab(a:integer;b:integer):integer;stdcall;
begin
result := a+b;
end;
exports ab;

begin
end.
------------------------------------------------------------------------
在MS SQL的查询分析器中执行如下语句来注册扩展存储过程.
USE master
go
EXEC sp_addextendedproc myproc, 'W_AddAB.dll'
go

但调用不了.exec master..myproc
提示:
ODBC: 消息 0,级别 16,状态 1
无法装载 DLL W_AddAB.dll 或该 DLL 所引用的某一 DLL。原因: 126(找不到指定的模块。)。
--------------------------------------------------------------------------

Q:
1,怎样在MS SQL里面怎样注册一个"扩展存储过程"?
2,注册之后,怎样去调用?
...全文
306 19 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
19 条回复
切换为时间正序
请发表友善的回复…
发表回复
internetcsdn 2004-11-25
  • 打赏
  • 举报
回复
internetcsdn 2004-11-24
  • 打赏
  • 举报
回复
有没有人试过用DELPHI写的DLL可以注册及调用的?
laker_tmj 2004-11-22
  • 打赏
  • 举报
回复
up learn
shaolin13108 2004-11-22
  • 打赏
  • 举报
回复
要加载dll很简单 你可以问问邹建啊
我喜欢用扩展存储过程 因为我喜欢vc++
不喜欢t-sql
shaolin13108 2004-11-22
  • 打赏
  • 举报
回复
netcoder(朱二)
你写的过程没有加载dll步骤呢
怎么会有结果
lsxaa 2004-11-22
  • 打赏
  • 举报
回复
TO: 回复人: netcoder(朱二)

不能嘛 我没试过
netcoder 2004-11-22
  • 打赏
  • 举报
回复
不能使用 regsvr32.exe 注册
netcoder 2004-11-22
  • 打赏
  • 举报
回复
1、建立一个dll,比如SQL Server自带的离子例子:hello.dll,在安装CD\DEVTOOLS\SAMPLES\ODS目录下

2、将这个dll放进%windir%\system32目录或者Program Files\Microsoft SQL Server\80\Tools\Binn目录

3、使用
use master
go
--将新扩展存储过程的名称注册到 Microsoft SQL Server 上。
sp_addextendedproc 'xp_hello', 'xp_hello.dll'
go

-- 执行
declare @txt varchar(33)
exec xp_hello @txt OUTPUT
select @txt AS OUTPUT_Parameter
go
--除去扩展存储过程。
sp_dropextendedproc 'xp_hello'
go

dbcc xp_hello(free)
go

4、注意事项:如果用vc编译xp_hello,项目中包含srv.h文件,而实际上srv.h有两个,一个是vc自带的,一个sql server自带的。
我们需要的是后者。为了避免冲突,可以把后者改个名字,比如srv_sql.h,然后在项目中包含。
netcoder 2004-11-22
  • 打赏
  • 举报
回复
你的dll是怎么做的?
扩展存储过程 不是一般的dll,具体的例子在安装光盘的DEVTOOLS\SAMPLES\ODS目录下

lsxaa 2004-11-22
  • 打赏
  • 举报
回复
需要先在注册表中注册 dll

开始/运行 输入 regsvr32.exe /i dllname

然后再在SQL中注册
internetcsdn 2004-11-22
  • 打赏
  • 举报
回复
internetcsdn 2004-11-21
  • 打赏
  • 举报
回复
up
internetcsdn 2004-11-18
  • 打赏
  • 举报
回复
回复人: titan90(touch net) ( ) 信誉:100 2004-11-17 16:22:00 得分: 0


扩展存储过程用sp_addextendedproc存储过程在SQL SERVER中注册


RE:
上面的就是用了sp_addextendedproc啊.
zhang_yzy 2004-11-17
  • 打赏
  • 举报
回复
不懂,帮顶
internetcsdn 2004-11-17
  • 打赏
  • 举报
回复
问题1已经解决
USE master
go
EXEC sp_addextendedproc ab, 'W_AddAB.dll'--ab为DLL里的函数名;
go

但执行
exec
master..ab 1,1
时,只提示命令已成功完成。
没有返回值(2)啊

???
YiOnLine 2004-11-17
  • 打赏
  • 举报
回复
ha
titan90 2004-11-17
  • 打赏
  • 举报
回复
扩展存储过程用sp_addextendedproc存储过程在SQL SERVER中注册
internetcsdn 2004-11-17
  • 打赏
  • 举报
回复
offer(煮熟的米饭) :
------------------------------------
declare @ab int
exec @ab=master..ab 1,1
---
命令已成功完成。
------------------------------------

declare @ab int
exec @ab=master..ab 1,1
select @ab

-----------
432562937

(所影响的行数为 1 行)
------------------------------------

????
offer 2004-11-17
  • 打赏
  • 举报
回复
看看这样可否:
declare @returnvalue int
Exec @returnvalue = master..ab 1,1

34,838

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧