Can this small function be sped up? VB6 COM ADO (2.8) question...new to this stuff!
- From: "Steve" <budgethelp@xxxxxxxxx>
- Date: 27 Jul 2005 10:55:12 -0700
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
.
- Prev by Date: Re: How can I tell what table a recordset is bound to?
- Next by Date: Re: calling stored procedure with optional parameter
- Previous by thread: RE: "Cannot create new connection because in manual or distributed tra
- Next by thread: ADO return varchar string with space trimmed
- Index(es):
Relevant Pages
|
|