dll:
procedure ConnRS(ConnStr,SqlStr:string);
var
ADO:TADOQuery;
begin
ADO.ConnectionString:=ConnStr;
ADO.Close;
ADO.SQL.Clear;
ADO.SQL.Add(SqlStr);
ADO.Open;
end;exports
ConnRs;窗体:
procedure ConnRs(ConnStr,SqlStr:string); stdcall;
external 'ConnRs.DLL';procedure TForm1.Button1Click(Sender: TObject);
begin
ConnRs('Provider=Microsoft.Jet.OLEDB.4.0;Data Source=db.mdb;Persist Security Info=False','select * from users');
end;
procedure ConnRS(ConnStr,SqlStr:string);
var
ADO:TADOQuery;
begin
ADO.ConnectionString:=ConnStr;
ADO.Close;
ADO.SQL.Clear;
ADO.SQL.Add(SqlStr);
ADO.Open;
end;exports
ConnRs;窗体:
procedure ConnRs(ConnStr,SqlStr:string); stdcall;
external 'ConnRs.DLL';procedure TForm1.Button1Click(Sender: TObject);
begin
ConnRs('Provider=Microsoft.Jet.OLEDB.4.0;Data Source=db.mdb;Persist Security Info=False','select * from users');
end;
解决方案 »
- 程序退出时,弹出错误提示框怎么办?
- 如何获得 outlook 的发件人地址 在OutlookApplication1ItemSend 的时候
- delphi访问ACCESS问题!
- 谁能给我一个 fastreport完整的例子,100分阿
- TComboBox的派生类中,如果希望对下拉框的列表显示的内容进行加工,覆盖了继承来这个方法没有效果,应该怎样做?
- 收到一封奇怪的邮件,删不掉?
- 我知道ListView1.Items[1].ImageIndex := 1;可以为LISTVIEW的第一个行...........
- 关于ADOQuery!100分
- 一个技术问题和一个非技术问题,初次提问,请高手们捧场!
- 谁知道关于delphi中单元的概念呢?就是unit?
- 急,如何让控件上的字闪烁
- rave如何设置这样常用的打印方式?
还有什么问题啊,帮我看看啊回 hthunter(核桃) :
加了Sharemem还是不行
另外dll中的函数声明也该加stdcall吧
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,ADODB,ACTIVeX,
Classes;{$R *.res}
procedure ConnRS(ConnStr,SqlStr:PCHAR);export;
var
ADO:TADOQuery;
begin
activex.CoInitialize(nil);
ADO:=TADOQUERY.Create(NIL);
ADO.ConnectionString:=ConnStr;
ADO.Close;
ADO.SQL.Clear;
ADO.SQL.Add(SqlStr);
TRY
ADO.Open; //如果执行不是返回DATASET的,用EXCUTESQL方法
FINALLY
ADO.Free ;
activex.CoUninitialize ;
END;
end;exports
ConnRs name 'ConnRs';
begin
end.