02-09-2020, 04:11 PM
MrSpock,
In the first of the two documents I linked to above, there are 2 notes:
1. To store session related variables, create members of the TUserSession class.
2. Do not work with variables declared in the var section, as these are global to all threads and won’t reflect session data properly.
As I read the two notes, the second of course is the culpit: never ever rely on vars not in usersession. However, the fist note holds a bit of a solution, and in combination with the description of User Session Overview (the second of the two links above) show how to add a an existing datamodule to the UserSession and how to create and destroy it in code in the usersession unit. For me I it means I should be able to create one datamodule, with one ADO DBConnection, and a number of ADOQoery or ADOStoredProc components, all being opened and linked together as part of the datamodule creation.
That way I should be able to open and execute SQL commands from my (later) created forms by using the prefix: UserSession.DM.ADOQuery1.
And for you, you should be able to create an empty imagefile, or a number of empty imageplaceholdes in the datamodule, and then use them in code at runtime. I'm not sure exactly what you do so this is just examples and a bit of guesswork, but I'm sure you get the idea.
I hope it will work like this and that my selects and table updates will be safe, once I have changed my application, just like I hope it will solve your problem. And I also hope those who know more about this, especially the AtoZed guys, will confirm this to be a possible solution.
Regards
Soren
In the first of the two documents I linked to above, there are 2 notes:
1. To store session related variables, create members of the TUserSession class.
2. Do not work with variables declared in the var section, as these are global to all threads and won’t reflect session data properly.
As I read the two notes, the second of course is the culpit: never ever rely on vars not in usersession. However, the fist note holds a bit of a solution, and in combination with the description of User Session Overview (the second of the two links above) show how to add a an existing datamodule to the UserSession and how to create and destroy it in code in the usersession unit. For me I it means I should be able to create one datamodule, with one ADO DBConnection, and a number of ADOQoery or ADOStoredProc components, all being opened and linked together as part of the datamodule creation.
That way I should be able to open and execute SQL commands from my (later) created forms by using the prefix: UserSession.DM.ADOQuery1.
And for you, you should be able to create an empty imagefile, or a number of empty imageplaceholdes in the datamodule, and then use them in code at runtime. I'm not sure exactly what you do so this is just examples and a bit of guesswork, but I'm sure you get the idea.
I hope it will work like this and that my selects and table updates will be safe, once I have changed my application, just like I hope it will solve your problem. And I also hope those who know more about this, especially the AtoZed guys, will confirm this to be a possible solution.
Regards
Soren

