Share datamodules between Intraweb and VCL projects - Printable Version +- Atozed Forums (https://www.atozed.com/forums) +-- Forum: Atozed Software Products (https://www.atozed.com/forums/forum-1.html) +--- Forum: IntraWeb (https://www.atozed.com/forums/forum-3.html) +---- Forum: English (https://www.atozed.com/forums/forum-16.html) +----- Forum: IntraWeb General Discussion (https://www.atozed.com/forums/forum-4.html) +----- Thread: Share datamodules between Intraweb and VCL projects (/thread-3813.html) |
Share datamodules between Intraweb and VCL projects - David1 - 01-22-2024 Hello, this is a more general architectural question than a specific Intraweb one...: I have a fully functional Intraweb application which manage some classes and data modules. I would like to leverage on these classes and data modules in a new VCL application. For the classes is enough to share files but for the datamodules (which leverage on FireDAC) I would like to know which is the best way to manage the connection to DB. In my Intraweb application all the datamodules refer to a connection component in the Usersession object. When I try to use them in the VCL application I relized I cannot use the Usersession unit (or at least I think is not the best solution) and I don't know how to manage the connection to the DB in the datamodules. I thinking about define a parameter to pass the connection in the datamodules constructor but perhaps there is a better solution. Which is the best way to share datamodules and address the FDConnection between IW and VCL projects? Thank you, Davide RE: Share datamodules between Intraweb and VCL projects - Alexandre Machado - 01-24-2024 Hi Davide, Been there, done that, a long time ago. IMO, the best way to do it is using code to link things instead of properties via Object Inspector. Something like this: Code: unit Unit1; Add a conditional define to your IW project (something like IW) and use it to isolate IntraWeb-specific code. Connect the DBConnection to the DataSets via code, using a code like this (that you can write once in a TDataModuleBase that would be the ancestor of all your DataModules). This simple arrangement works well for this kind of scenario. Have in mind that global variables like that one that Delphi creates for you (var DataModule1: TDataModule1) is a no-no in IntraWeb applications. |