主程序用TUniConnection连接数据库,调用dll时把TUniConnection作为参数传给dll。
结果数据控件OPEN时出错。(dll中有无 TOracleUniProvider都一样,dll作为单独程序运行没问题)。程序原来用ADO控件是没问题的,换uniDAC就不行了。UNIDAC

解决方案 »

  1.   

    ActiveX 有没有对其初始化?
    用:  ActiveX.CoInitialize(nil);    //对ActiveX 初始化
      

  2.   

    已经初始化了。dll里的form打开正常:procedure show_exform(conn:TUniConnection;saccount:pchar;scode:pchar);stdcall;
    begin
      try
      CoInitialize(nil);
      if cdForm=nil then
        cdForm:=TcdForm.Create(nil);
      con1:=conn;
     if not con1.Connected then
         con1.Connected:=True; // 
      account:=saccount;
      cdForm.ShowModal;
      finally
        con1.Connected:=False;
        CoUninitialize();
        if cdForm<>nil then
        begin
          cdForm.Free;
          cdForm:=nil;
        end;
      end;
    end;
      

  3.   

    真是奇怪,两边加了sharemem,在delphi7里解决了,delphi2010还是不行,把delphi2010里的borlndmm.dll拷贝到运行目录也没用。
      

  4.   

    mydac也存在一样的情况,给你一个MYDAC的参考,至于 UDAC 是不是一样的,我就不能确定了。
    DLL内部的窗体开发编译的时候,数据集一定要关闭。在mydac下,有个MyServices.pas单,找到 
    procedure TCustomMyDataSetService.FillFieldDescs(out FieldDescs
      : TFieldDescArray; FillKeyFieldDescs, ForceUseAllFields: boolean);begin
      FieldDescs := nil;  if (FDataSet.Fields.Count = 0) or (GetIRecordSet.Fields.Count = 0) then
        Exit;  for i := 0 to FDataSet.Fields.Count - 1 do
      begin
        Field := FDataSet.Fields[i];
        if Field.FieldKind = fkData then
        begin
          if FDataSet.GetFieldDesc(Field) is TMySQLFieldDesc then // 这是修改的
            FieldDesc := FDataSet.GetFieldDesc(Field) as TMySQLFieldDesc;      IsNeedProcessField := ForceUseAllFields or // (Self is TCustomMyTable) or
            (FieldDesc.TableInfo = UpdatingTableInfo) or
            ((FieldDesc.TableInfo = nil) and
            not FDataSet.Options.SetFieldsReadOnly);      if IsNeedProcessField then
            ProcessField(FieldDesc);
        end;
      end;  if FillKeyFieldDescs then
        CheckPrimaryKeys;
    end;
      

  5.   

    试了一下,好像只能在DLL新建一个uniCONNECTION,再 AssignConnect。
    而不能直接赋值,不然会出Invalid class typecast的问题。
    这样每个dll都有一个链接,增加数据库的连接数,没啥意思了。
      

  6.   

    我用ADOconnectec,mydac都没问题的。。
      

  7.   

    uniDAC里面好像就是封装了其它控件?里面有ODAC的包的单元,是一样的。