Board index » delphi » Open and Close ADO components in ISAPI app

Open and Close ADO components in ISAPI app

When do I open and close ADO Components in an ISAPI application
Obviously I open them as soon as a request is made for a query
but do I close them directly after the query has completed.

And then re-open them each time I want to access the DB, and also
pass the login password back to the query each time I need access

If I open and close the ADO Query/Connection etc on each request
does this make my apps safer for code-threading i.e. an open
connection won't be left{*word*154} somewhere in memory ?

Is this the right way to access via ADO and ISAPI, how would this
affect the speed of my application taking into consideration it
might be used by numerous users ?

Thanks for your help

Elfyn

 

Re:Open and Close ADO components in ISAPI app


Open the connection in the webmodulecreate event and close it in the
webmoduledestroy event..Leave your connections open if connecting to MS SQL
Server and connection pooling will happen automatically, (in essence you
will have one connection to the db and let IIS manage it.) This will save
mucho overhead of connecting on every hit ... that's {*word*156} the machine.
You dont have to worry about "threading" as the ado components are
threadsafe but if you really mean "state management" , then just open a
tadodataset (for instance) , do you sql, process your data and forget it. No
need to close it, just causes overhead cuz your gonna use it again
...(unless you only have one visitor per day).  Remember though, the web is
stateless and you have to requery every time your webmodule is invoked by
IIS.

Check the the FAQ at Expressweb Framework. Jimmy has good answer there about
"coInitialize" and it is a must for ISAPI programmers.

HTH

Del

Re:Open and Close ADO components in ISAPI app


Dell,

Thanks very much for your reply, but where do I find the FAQ
for ExpressWeb framework ?

Thanks

Elfyn

Other Threads