Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
For Alexandre: Regarding Datamodules and DB components
#1
Hi Alexandre,

This is for you, but everybody else please feel free to comment as well:

You once recommended I put the DBConnection in the UserSession, and then created a datamodule for every form I make, where DB related components should be placed. For me, as you probably all know by now, the DB related components I use is an ADO DBConnection in UserSession, and ADO the components are ADOQuery and ADOStoredproc, in the datamodules.

With my newfound knowledge of how and where to put variables, coming from other users comment on this forum (thanks to all) and going through a lot on threads in this forum, a lot of documentation on your homepage, a lot of googled information, and some of the older IW forum entries on then Embarcadero site. During all the reading I believe I am certain that ANY form I create at runtime, and any procedure and function I use, and any variable, local for a form or global in UserSession, is safe form interference from other sessions, provided everything is defined within the limits of the Form Class. That is, from Private / Public down to the END definition for the class. Local vars and procedure / function definitions are no go !!

Can you confirm that that is a correct assumption ?

Also, that the datamodule I need for a form, is included in the forms uses list, defined as dm:= {moduleclassname}; in the private section of the form class, and created in the forms create event with dm := {datamoduleclassname}.create(self); I take it that that is correct as well ?, though I do understand there are room for differences like that the datamodule do NOT HAVETO be created in the forms oncreate event, as long as it is created before it's needed, and that it can have any name, not necessarily "dm".

Finally, I have come to learn, and I am not sure you did not already tell me that long time ago, that it is vital that settings for the ADO components connection property is done in the datamodule at runtime, like in the DataModule OnCreate event, and not at design time. Other users have mentioned that as well (again thanks to you).

And that is all there is too it, I believe. Can you confirm that ?

I know ADO are not thread safe, and if I created threads within my form, I should handle threads and make them safe, but also that as long as I do not create threads, it is not necessary. The Session, and among that the ADO components, is shielded from access from other sessions.

Is there anything else I should be aware of, that you (or any of you reading this) can think of ?

I thank you a lot for the information you cave me a long time ago (9 months) and I just wish I could have remembered it all. It would have saved me from a lot of anger and extra work. But such is life. What does not kill you makes you stronger, and what you learn by trial and error, is easier remembered than written words.

Regards
Soren
Reply


Messages In This Thread
For Alexandre: Regarding Datamodules and DB components - by SorenJensen - 02-10-2020, 12:57 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)