03-20-2023, 02:24 AM
(03-18-2023, 12:52 PM)Mikael Nilsson Wrote:UserSession (TUserSession) is a very special data module. You get to determine the contents of it, and it is available per session at runtime. That is, each session has its own copy of UserSession. IW completely manages the creation/destruction/visibility of UserSession. You can create your own data module, then make it a part of UserSession like:(03-18-2023, 03:35 AM)DanBarclay Wrote:(03-16-2023, 02:17 PM)raulevm Wrote: Thanks for answering. In the old intraweb documentation (the only one there is from 20 years ago), the examples I use, forum readings, and people using IW all indicate that a data module can be used. There is no documentation that says that FireDAC cannot be used with a data module. Thank you
A datamodule can be used, you just need to create the datamodule within the UserSession module. This makes it a part of the session.
Dan
Please explain why you want an extra Datamodule.
Code:
Type
public
MyDataMod: TMyDataMod;
procedure TUserSession.DataModuleCreate(Sender:TObject);
begin
myDataMod:=TMyDataMod.Create(nil);
end;
procedure TUserSession.DataModuleDestroy(Sender:TObject);
begin
freeandnil(myDataMod);
end;Doing that makes your datamodule available, but a part of UserSession.
UserSession.myDataMod....
I'm not sure of Firedac requirements, you may be able to share a common connection but I suspect including the connection (per session) in the data module would be more robust. THere are a number of demos online with data connections and I believe they may be using datamodules.
Dan

