Board index » delphi » Multiple datamodules in one dll/cgi?

Multiple datamodules in one dll/cgi?

I would like to be able to use bde and ibx in the same app, depending on
a setting in an external initiation file.
A while ago Craig suggested I instantiate the right datamodule the
moment it is needed. Like:

type
 DataAccessToolType = (datBDE, datIBX, datADO, ....);

procedure CreateDM;
begin
  case DataAccessTool of:
    datBDE : FDM := TBDEDM.Create(self);
    datIBX   : FDM := TIBXDM.Create(self);
  end;
end;

I tried to do something like this, but am running into trouble with the
declaration of the FDM variable. I either declare it as TBDEDM, in which
case I cannot assign it to a TIBXDM and vice versa. Keeping the
declaration as global inside the respective datamodules (the var section
before implementation) gives similar problems, because only the last
module of the two in the uses clause is retained by the compiler.
And this is just the creation part. After this you still need to access
the different properties of for instance the tDatabase and tIBdatabase
component.

How do you "overload" these instances?  None of the documentation and
books I looked through mention this sort of thing?

Any pointers appreciated.
Lewie

 

Re:Multiple datamodules in one dll/cgi?


Hi,

I've not seen the previous suggestions, but by the sounds of things you need
to create a base Datamodule class and then derive TBDEDM and TIBXDM from
this base datamodule, implementing where necessary...  (or something like
that.)  You're going to have to think up a nice abstract interface to your
datamodules, put that in the base class, and then implement the interface in
the derived datamodules.

HTH

Walter Prins

Quote
"Lewie Dekker" <lewi...@putra.net.my> wrote in message

news:3BCE93A9.DAE7D7F9@putra.net.my...
Quote
> I would like to be able to use bde and ibx in the same app, depending on
> a setting in an external initiation file.
> A while ago Craig suggested I instantiate the right datamodule the
> moment it is needed. Like:

> type
>  DataAccessToolType = (datBDE, datIBX, datADO, ....);

> procedure CreateDM;
> begin
>   case DataAccessTool of:
>     datBDE : FDM := TBDEDM.Create(self);
>     datIBX   : FDM := TIBXDM.Create(self);
>   end;
> end;

> I tried to do something like this, but am running into trouble with the
> declaration of the FDM variable. I either declare it as TBDEDM, in which
> case I cannot assign it to a TIBXDM and vice versa. Keeping the
> declaration as global inside the respective datamodules (the var section
> before implementation) gives similar problems, because only the last
> module of the two in the uses clause is retained by the compiler.
> And this is just the creation part. After this you still need to access
> the different properties of for instance the tDatabase and tIBdatabase
> component.

> How do you "overload" these instances?  None of the documentation and
> books I looked through mention this sort of thing?

> Any pointers appreciated.
> Lewie

Re:Multiple datamodules in one dll/cgi?


Well, Craig seemed to suggest that it was dead simple to do, so obviously I'm
missing something here. But I too had thought one would need to create a
basemodule and desend the rest from it. In theory that is possible, using the
same names for components, but in practice you deal with different properties
for these components and you can never access these. Unless you completely
redefine all the vcl components for databse access and overloading all
properties.
I'm fairly sure that is not what he meant. But I'll keep plodding along....

Lewie

Other Threads