02-07-2020, 05:10 AM
(This post was last modified: 02-07-2020, 05:13 AM by SorenJensen.)
Hi zsleo,
Again thanks for your input. And sorry for asking you to clarify a doubt:
I have only one ADO DBConnection defined in UserSession, with the needed connectionstring set (build and tested using it's integrated build function), and for all forms I have a number of either ADOQuery or ADOStoredProc in datamodules, created for and used by each form. Each time I create and show a form, I create the Datamodule (defined as a private property of the form) used by that form in it's IwAppFormCreate event, and in the datamodule, in it's datamodulecreate event, I set the Connection property of each ADOQuery or ADOStoredProc to the connection of the ADO DBConnection in the UserSession form.
Each ADOQuery and ADOStoredProc has a Connection property and a Connectionstring Property. As defined above, I set the Connection property to the ADO DBConnection in UserSession.
a. If I understand you correctly, I should get rid of the ADO DBConnection in the UserSession module, and instead set the ConnectionString of EACH ADOQuery or ADOStoredProc I use in my project, to the same value as the connectionstring of my current ADO DBConnection. Is that correct ?
or b. are you proposing that I, for each ADOQuery or ADOStoredProc I have placed on my datamodules, I also place an ADO DBConnection (with a unique name), and set the connection property of the ADOQuery to that ADO DBConnection. In this way, an ADOQuery or an ADOStoredProc always form a unique pair with a ADO DBConnection.
If it is a. how do I make the actual connection ? just by opening (activating) the ADOQuery or ADOStoredProc ? and
if it is b. should I then activate (Connect) the ADO DBConnection just before I activate the corresponding ADOQuery, and close connection again when the ADOQuery is done, or would I activate the ADO DBConnection in the forms FormCreate event and close it in the FormClose event ?
I'm sorry to ask this, but could you show me an example code for how you do these things ?
Many, many thanks in advance.
Regards
Soren
Again thanks for your input. And sorry for asking you to clarify a doubt:
I have only one ADO DBConnection defined in UserSession, with the needed connectionstring set (build and tested using it's integrated build function), and for all forms I have a number of either ADOQuery or ADOStoredProc in datamodules, created for and used by each form. Each time I create and show a form, I create the Datamodule (defined as a private property of the form) used by that form in it's IwAppFormCreate event, and in the datamodule, in it's datamodulecreate event, I set the Connection property of each ADOQuery or ADOStoredProc to the connection of the ADO DBConnection in the UserSession form.
Each ADOQuery and ADOStoredProc has a Connection property and a Connectionstring Property. As defined above, I set the Connection property to the ADO DBConnection in UserSession.
a. If I understand you correctly, I should get rid of the ADO DBConnection in the UserSession module, and instead set the ConnectionString of EACH ADOQuery or ADOStoredProc I use in my project, to the same value as the connectionstring of my current ADO DBConnection. Is that correct ?
or b. are you proposing that I, for each ADOQuery or ADOStoredProc I have placed on my datamodules, I also place an ADO DBConnection (with a unique name), and set the connection property of the ADOQuery to that ADO DBConnection. In this way, an ADOQuery or an ADOStoredProc always form a unique pair with a ADO DBConnection.
If it is a. how do I make the actual connection ? just by opening (activating) the ADOQuery or ADOStoredProc ? and
if it is b. should I then activate (Connect) the ADO DBConnection just before I activate the corresponding ADOQuery, and close connection again when the ADOQuery is done, or would I activate the ADO DBConnection in the forms FormCreate event and close it in the FormClose event ?
I'm sorry to ask this, but could you show me an example code for how you do these things ?
Many, many thanks in advance.
Regards
Soren