Click to See Complete Forum and Search --> : help with database


eyalmolad
March 1st, 2000, 01:33 PM
i am writing com dll in VB. i have 4 functions that returns recordset. i want to ask for advice where to put the line that opens my connection

at the beginning of every function and close at the end or open a connection in init function of the com and close in terminate function.
thanks

b_vinay
March 1st, 2000, 01:52 PM
I am not sure what is the best practice... but I would suggest it is better to open the connection within each function and close it within the function... Advantage of doing so is that you will not have the connection open until the object is destroyed....

Johnny101
March 1st, 2000, 02:02 PM
Its generally better, if possible, to not maintain a connection to the database. So my suggestion would be open the connection at the beginning of the sub, and then close it at the end. Or, which may be even better, pass a connection object to that routine, so that your dll wont have to create a connection which could leave open more connections for other instances.

This is especially true if your dll is going to be used in MTS, or any situation where it's going to be used as a "middle tier" object.

hope this helps,
John

John Pirkey
MCSD
www.ShallowWaterSystems.com