devxlogo

Returning Recordsets From COM Components

Returning Recordsets From COM Components

Question:
I have heard from some that it is a bad idea to return recordsets from COM components and that you should populate a variant array and send that back to the ASP page instead. Others have said that MTS handles the connection pooling (and all those other MTS features), regardless. Returning a recordset is easier, but what difference does it make?

Answer:
I personally like sending back disconnected recordsets from my components. You don’t have to worry about maintaining the database connection, plus you don’t have to mess with the Variant array method.
I’m not sure what the party line is these days, but changing the CursorLocation property to adUseClient and then setting the ActiveConnection to Nothing disconnects the recordset. I use this quite successfully in a number of components I currently have running. I let MTS manage a separate component that maintains a database connection and returns disconnected recordsets as needed.

See also  Professionalism Starts in Your Inbox: Keys to Presenting Your Best Self in Email
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist