Can this small function be sped up? VB6 COM ADO (2.8) question...new to this stuff!



I've created an Excel COM add-in, compiled as a dll in VB6, that
enables some UDFs (user-defined-functions) that run database queries on
multiple, separate databases. I store the separate connections in the
dimensionalized variable cnt()

My question is, Is there any way to change the code to make the process
any faster? It takes about 13 seconds to process 60,000 queries, which
is pretty fast, but can it be made any faster?

Should I not instantiate / destroy the cmd and rst objects in the
functions, and only do so upon the add-in's connection and
disconnection events?

Is there a way to skip the explicit reference, "Set
cmd.ActiveConnection = cnt(intCompanyNumber)", and perform the
operation from the recordset itself?

I'm not familiar with the ADO object model (2.8 is what I'm using.)

Stupid question but, Does a connection have to be the "ActiveConection"
to be queried?

Any advice or insights would be much appreciated. As I said, I'm new to
all this.

Condensed code below:

'BEGINNING OF FUNCTION, STRIPPED DOWN TO BASICS
Dim cmd As New ADODB.Command
Dim rst As New ADODB.Recordset

Dim recArray As Variant

Set cmd.ActiveConnection = cnt(intCompanyNumber)
cmd.CommandText = SqlQueryString

Set rst = cmd.Execute

If rst.BOF = False And rst.EOF = False Then
recArray = rst.GetRows
ReturnValueofFunction = recArray(0, 0)
Else
ReturnValueofFunction = 0
End If

rst.Close
Set rst = Nothing
Set cmd = Nothing
'END OF FUNCTION

Thank you,

Steve Feldman budgethelp@xxxxxxxxx

.



Relevant Pages

  • Can this small query be sped up any?
    ... enables some UDFs that run database queries ... on multiple, separate databases. ... Set rst = Nothing ...
    (microsoft.public.vb.database.ado)
  • Re: Dealing with large recordsets
    ... "MyRecID" is the field that is numbered to be able to select groups of records instead of all the records. ... Dim i As Integer, k As Long ... Set rst = db.OpenRecordset ... I run a series of queries on this table to create what is essentially a pivot table in Access 2000. ...
    (microsoft.public.access.modulesdaovba)
  • Re: Forcing a ReQuery
    ... queries 1 and 2, which you say works correctly, or in the fact that queries ... > Dim dbs As DAO.Database ... > Set rst = qdf.OpenRecordset ... > Set qdf = Nothing ...
    (microsoft.public.access.modulesdaovba)
  • Forcing a ReQuery
    ... I have four queries which are run in sequence. ... For #1 and #2 I reset the SQL based on User Form entries. ... Set rst = qdf.OpenRecordset ...
    (microsoft.public.access.modulesdaovba)
  • SQL Server Application roles
    ... I started using application roles but I have problems with database queries ... that are executed in separated threads. ... I execute sp_setapprole with an application role that has full access to ...
    (borland.public.delphi.database.ado)