同在一个DLL中,单独的一个数据模块,为什么数据集控件连接到它的并且打开的时候出现“missing Connection or ConnectionString”错误??在我DLL项目里有一个共用的数据模块,里面就一个ADOConnection,其他的窗体上的数据集ADOQuery都是连的它,在设计时期,ADOQuery都可以打开,而且可以看到里面的字段和数据,为什么程序一运行过后,再打开ADOQuery的时候就显示“missing Connection or ConnectionString”的错误?如果我把ADOConnection放到当前数据集所在的窗体上就不会了!是不是DLL里面用数据模块还有什么规则啊?查过很多资料,可就是解决不了!大家帮我看看!!在线等!!

解决方案 »

  1.   

    注明一下:
    在DLL的接口函数中我有创建数据模块,代码如下:library DLL;{ 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
      Windows,
      SysUtils,
      forms,
      Classes,
      ActiveX,
      dll_pds_Unit in 'dll_pds_Unit.pas' {pds},
      dll_cache_Unit in 'dll_cache_Unit.pas' {cache: TDataModule};{$R *.res}
    var
      DLLApp: TApplication;
      DLLScr: TScreen;procedure CreateDllForm(App: TApplication; Scr: TScreen); stdcall;
    begin
      Application := App;
      Screen := Scr;
      cache := Tcache.Create(nil);
      //Application.CreateForm(Tcache, cache);这种方法也用过
      mdi := Tmdi.Create(application);
      mdi.Show;
    end;procedure ExitDLL(Reason: Integer);
    begin
      if Reason = DLL_PROCESS_DETACH then
      begin
        Application := DLLApp;
        Screen := DLLScr;
      end;
    end;exports
      CreateDllForm;begin
      DLLApp := Application;
      DLLScr := Screen;
      CoInitialize(nil);
      DLLProc := @ExitDLL;
    end.
      

  2.   

    cache  :=  Tcache.Create(nil);  
       //Application.CreateForm(Tcache,  cache);这种方法也用过  cache就是数据模块窗体
      

  3.   

    //如果我把ADOConnection放到当前数据集所在的窗体上就不会了!
      cache := Tcache.Create(nil);
      //Application.CreateForm(Tcache, cache);这种方法也用过
      mdi := Tmdi.Create(application);  mdi.query1.connet... := cache.adoconnection这样试验下
      

  4.   

    问题解决了,要在窗体Create的时候手动的再进行一次连接:mdi.query1.connet...  :=  cache.adoconnection