gesulmino Posted June 26, 2025 Posted June 26, 2025 Hi all, sometimes it happened that a form in two different sessions shared the same data module. What techniques should I adopt to avoid this from happening? Quote
Sherzod Posted June 26, 2025 Posted June 26, 2025 Hello, Each user session in uniGUI should have its own instance of the DataModule. Could you please clarify your specific case a bit more? For example, where and how are you creating the DataModule? Quote
gesulmino Posted June 26, 2025 Author Posted June 26, 2025 Ciao, Now I use this constructor for any TUniFrame inherited from TfmUGBase, that are inserted in a TUniTabSheet, so it works very fine. //TfmUGDialog is a TUniFrame function TfmUGDialog.GetDataModule<T>(DMClass: TDataModuleClass): T; begin Result := T(UniApplication.UniMainModule.GetModuleInstance(DMClass)); end; //TfmUGBase inherit from TfmUGDialog constructor TfmUGBase.CreateService(AOwner : TComponent; SqlConnection : TFDCustomConnection; aDataModuleClass : TDataModuleClass; aEnv : TAmbiente; Modulo : string; connectmode : TUserProfileLevel); begin inherited CreateService(AOwner, SqlConnection, aDataModuleClass, aEnv, Modulo, connectmode); //create of datamodule FInstanceDM := GetDataModule<TdmUGBase>(aDataModuleClass); FInstanceDM.InitChild(SqlConnection, connectmode); FInstanceDM.Ambiente := aEnv; // binding of Datasource property of each data-aware component in the frame with TDatasource in FInstanceDM BindAllDataSourcesToSessionModule(FInstanceDM) end; Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.