求标准DLL封装ADO访问SQLSERVER的方法

kunsl 2003-10-18 10:35:50
谢谢
...全文
104 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
Devlopered 2003-10-27
  • 打赏
  • 举报
回复
up
txlicenhe 2003-10-20
  • 打赏
  • 举报
回复
自己写吧
1:连接
2:查询
3:执行
...
kunsl 2003-10-20
  • 打赏
  • 举报
回复
UP一下
zzh54zzh 2003-10-20
  • 打赏
  • 举报
回复
library tmpdll;

{ 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
ADODB;
Windows;
var
ADOQuery: TADOQuery;
ADOQueryConStr, ADOQuerySQLStr: String;
{$R *.res}
procedure FreeProc; stdcall;
begin
if ADOQuery <> nil then
begin
ADOQuery.Free;
ADOQuery := Nil;
end;
end;

procedure MyDLLHandler(Reason: Integer);
begin
case Reason of
DLL_PROCESS_ATTACH:
begin
ADOQuery := TADOQuery.Create(nil);
end;
DLL_PROCESS_DETACH:;
DLL_THREAD_ATTACH:;
DLL_THREAD_DETACH:;
end;
end;

//赋连接字符串
procedure SetADOQueryConStr(vADOQueryConStr: String); stdcall;
begin
ADOQueryConStr := vADOQueryConStr;
end;

//赋SQL命令
procedure SetADOQuerySQLStr(vADOQuerySQLStr: String); stdcall;
begin
ADOQuerySQLStr := vADOQuerySQLStr;
end;

//执行
function ADOQueryExecSQL: boolean; stdcall;
begin
ADOQuery.ConnectionString := ADOQueryConStr;
ADOQuery.Close;
ADOQuery.SQL.Clear;
ADOQuery.SQL.Add(ADOQuerySQLStr);
try
ADOQuery.ExecSQL;
except
Result := False;
exit;
end;
Result := True;
end;

exports
FreeProc,
SetADOQueryConStr,
SetADOQuerySQLStr,
ADOQueryExecSQL;
begin
DLLProc := @MyDLLHandler;
MyDLLHandler(DLL_PROCESS_ATTACH);
end.

ly_liuyang 2003-10-19
  • 打赏
  • 举报
回复
注意ActiveX要初始化的Coinitlize什么的API一定要用!
biu 2003-10-19
  • 打赏
  • 举报
回复
你想导出什么类型的数据呢 dll里面使用ado和application 没有区别
kunsl 2003-10-19
  • 打赏
  • 举报
回复
是要封装对sqlserver的操作在DLL里。
kunsl 2003-10-19
  • 打赏
  • 举报
回复
各位能有例子。
hfrui 2003-10-18
  • 打赏
  • 举报
回复
ADO已经封装得很好了,何苦呢?
hthunter 2003-10-18
  • 打赏
  • 举报
回复
这问题太广了,具体是什么?
DLL内部访问SQL SERVER跟普通的Application的访问并没有什么两样啊

2,497

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 数据库相关
社区管理员
  • 数据库相关社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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