这里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等组件啊!那个朋友还能给点代码我看看!谢谢哦!

解决方案 »

  1.   

    'select * from name where name='''+strtime+''''
    这里写错了吧
    dll的参数用pchar传
      

  2.   

    to : lining_1977(李宁) 我检查了在执行这句DataModule1.ADOQ.Close;的时候出错的
    如果可以的话,我可以把代码发给你,给我看看,留下你的邮箱地址就可以了!
      

  3.   

    [email protected]
    你的ADOQ是打开的码
      

  4.   

    function Data(strtime:string):boolean;stdcall;
    begin
      result:=false;
      with DataModule1.ADOQ do
       begin
         Close;
         SQL.Clear;
         SQL.Add('select top 1 * from Tabname where name='+''''+strtime+'''');
         Open;
         If RecordCount>1 then   result:=true;
         Close;
       end;
    end;
      

  5.   

    上面这行写错了:
      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
      

  6.   

    这句话DataModule1.ADOQ.Close,该这么写:DataModule1.Close
      

  7.   

    该函数好像不认识DataModule1,是不是该函数访问不了外部的变量,在函数里动态建立adoquery
    应该没有问题吧?
      

  8.   

    估计应该是不能访问或调用close时发现对象有问题,仔细检查一下
    [email protected]
      

  9.   

    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;