这里library Project1;的中程序
function Data(strtime:string):boolean;stdcall;
begin
result:=false;
with DataModule1.ADOQ do
begin
DataModule1.ADOQ.Close; 执行的时候这里出错了!
DataModule1.ADOQ.SQL.Clear;
DataModule1.ADOQ.SQL.Add(select * from name where name=+strtime);
DataModule1.ADOQ.Open;
if DataModule1.ADOQ.RecordCount>1 then
begin
result:=true;
end;
end;
end;
exports
Data;
begin
end.
编译的时候没有错误,执行的就错了!
在DLL程序中到底是怎么调用ADOQuery和ADOTable等组件啊!
那个朋友还能给点代码我看看!谢谢哦!
lining_19772002@yahoo.com.cn
你的ADOQ是打开的码
上面这行写错了:
SQL.Add(select top 1 * from Tabname where name=++strtime+);
应为:
SQL.Add(select top 2 * from Tabname where name=++strtime+);
或者将 If RecordCount>1 改为: If RecordCount>0
function Data(strtime:string):boolean;stdcall; //你的DataModule1都没有创建,怎么能用呢
begin
result:=false;
CoInitialize(nil); //uses ActiveX;
try
DataModule1 := TDataModule.Create(Application);
with DataModule1.ADOQ do
begin
DataModule1.ADOQ.Close; 执行的时候这里出错了!
DataModule1.ADOQ.SQL.Clear;
DataModule1.ADOQ.SQL.Add(select * from name where name=+strtime);
DataModule1.ADOQ.Open;
if DataModule1.ADOQ.RecordCount>1 then
begin
result:=true;
end;
end;
finally
FreeAndNIl(DataModule1);
Couninitialize;
end;
end;