*******dll中可以传一个数据连接吗?*******

a9a9a9 2002-04-12 04:16:09
我不想再dll中创建adoconnection,有其它办法吗?
如果再dll中创建adoconnection应该注意些什么?
...全文
23 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
a9a9a9 2002-04-12
  • 打赏
  • 举报
回复
不行啊!
Access Violation at address 77991485 in module 'oldaut32.dll'.read of address 0013c000
//----------------------代码如下--------------------------------
library Account;

uses
SysUtils,
Classes,
ADOdb;

type
{$R *.RES}

function GetAccountInfo(ADOCnn: TADOConnection; uAccount, uPassword: WideString; out uStaffId: integer; uName: WideString): integer; stdcall;
var
AdoQry: TAdoQuery;
begin
Result := 1;
if (not length(uAccount) > 0) and (not length(uPassword) > 0) then
begin
Result := 1;
exit;
end;

if ADOCnn.Connected then
begin
AdoQry := TAdoQuery.Create(nil);
with AdoQry do
begin
Connection := AdoCnn;
Close;
SQL.Clear;
SQL.Add('select * from Vacc0204_ActiveAcountInfo where Account=' + '''' + uAccount + '''' + ' and uPassword=' + '''' + uPassword + '''');
try
Open;
if RecordCount > 0 then
begin
First;
uStaffId := FieldByName('StaffID').asinteger;
uName := FieldByName('Pname').asstring;
Result := 0;
end
else begin
Result := 1;
end;
except
Result := 1;
end;
Close;
Free;
end;
end
else Result := 1;
end;

exports
GetAccountInfo;
begin

end.
a9a9a9 2002-04-12
  • 打赏
  • 举报
回复
ADOT:=TADOTable.create(nil);

nil 不会对释放什么的有影响吧?
wangeren 2002-04-12
  • 打赏
  • 举报
回复
我刚刚测试测试过!
wangeren 2002-04-12
  • 打赏
  • 举报
回复
library Project1;

uses
SysUtils,
Classes,
Windows, Messages,Graphics, Controls,
Db, ADODB;
{$R *.RES}

Function shihuafei(shichang:integer;ADOC:TADOConnection):currency ;stdcall;
var
ADOT:Tadotable;
qsd:integer;
qfl:Currency ;
hsd:integer;
hfl:Currency ;

begin
ADOT:=TADOTable.create(nil);
ADoT.Connection:=Adoc;
Adot.TableName:='syscfg';
Adot.Active :=True;

AdoT.Locate('note','市话前几分钟计费时间段',[loPartialKey]);
qsd:=strtoint(Adot.fieldbyname('syscfg').asstring);
AdoT.Locate('note','市话前3分钟费率',[loPartialKey]);
qfl:=strtocurr(Adot.fieldbyname('syscfg').Asstring);
AdoT.Locate('note','市话几分钟后的计费时间段',[loPartialKey]);
hsd:=strtoint(Adot.fieldbyname('syscfg').asstring);
AdoT.Locate('note','市话以后每分钟费率',[loPartialKey]);
hfl:=strtocurr(Adot.fieldbyname('syscfg').asstring);
ADOT.free;
if shichang<=qsd then Result:= qfl
else if ((shichang-qsd) mod hsd)<>0 then result:= ((shichang-qsd) div hsd +1)* hfl + qfl
else result:= ((shichang-qsd) div hsd)* hfl + qfl;
end;
exports
shihuafei;

end.
memphis2 2002-04-12
  • 打赏
  • 举报
回复
好象不行,如果能解决请copy给我一份
gcf@263.net
thanks
a9a9a9 2002-04-12
  • 打赏
  • 举报
回复
我是想把一些常用的查询放在dll中,如帐号登陆,查询帐号权限。
各位有没有这方面的经验。
a9a9a9 2002-04-12
  • 打赏
  • 举报
回复
dll可以用外面的datamodule吗?
dll可以建立自己的datamodule吗?
谢谢!
yixia 2002-04-12
  • 打赏
  • 举报
回复
dll里的adoconnection一般只测试一下能不能连上数据库把


要是用于操作的最好放到,和adoquery,adotable一块的位置
比如form上
或者datamoudle里
-------------------------------------------------------------------------------- 飞鸽书 (IP Messenger) Ver2.06 Copyright (C) 1996-2004 SHIROUZU Hiroaki All Rights Reserved. -------------------------------------------------------------------------------- 目录: 1. 软件简介 2. 许可协议 3. 系统要求 4. 使用说明 5. 相关信息 6. 广域网设置(广播设置) 7. 补充 8. 支持 9. 更新历史 10. 感谢 ================================================================================ 重要说明: comctl32.dll(公共控件) 要求 4.71 或以上版本 更多信息请参见 "系统要求" ================================================================================ -------------------------------------------------------------------------------- 1. 软件简介 - IPMsg 是一款局域网内即时通信软件, 基于 TCP/IP(UDP). 可运行于多种操作平台(Win/Mac/UNIX/Java), 并实现跨平台信息交流. - 不需要服务器支持. - 支持文件/文件夹的送 (2.00版以上) - 通讯数据采用 RSA/Blofish 加密 (2.00版以上) - 十分小巧, 简单易用, 而且你可以完全免费使用它 - 目前已有的版本包括: Win32, Win16, MacOS, MacOSX, X11, GTK, GNOME, Java 等, 并且公开源代码. 请查看以下地址以获得相关信息: http://www.ipmsg.org/ -------------------------------------------------------------------------------- 2. 许可协议 (BSD License) Copyright (c) 1996-2004 SHIROUZU Hiroaki All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of the SHIROUZU Hiroaki nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRI

5,386

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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