Currently I’m trying to create some coding short cuts for our website. Right now to query a database and return a record set 2 functions have to be called:
GetDBConn returns an open ado connection object to the connection string passed in.
GetRS returns a record set object based on the ado connection and sql passed in.
set objConn = GetDBConn(connString, commandTimeout, connTimeout, cursorType)
set objRs = GetRS(objConn, sql)
I want to essentially write those two as a single function but my question really becomes this… I am pretty sure that you’re supposed to close and destroy your ado connections when done with them. If I dim the connection inside the new function, query the database and return the record set, I can’t close and destroy the connection inside the function or else the record set returned by the function becomes useless (i.e. that connection object is never explicitly closed/destroyed). Is that ok? Will it have any negative impact on the SQL/Web Servers?
Thanks
Not closing connections will cause problems with your SQL server’s resources. Depending on your hardware and how many connections are getting established, you may not notice a problem. Or it may make the server inaccessible…