Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query is VERY slow in code?

Status
Not open for further replies.

mymou

Technical User
May 21, 2001
355
GB


Hi All

Trying to do something very simple. Run a query that has a parameter using code.

To run the query in QBE is fine taking very little time (so I can assume that all indexes etc are fine). But when i try to run the code below it works as expected but does a massive pause.


Dim cat As New ADOX.Catalog
Dim cmd As ADODB.Command
Dim rs As ADODB.Recordset

cat.ActiveConnection = CurrentProject.Connection
Set cmd = cat.Procedures("qrySingleEquity").Command ' This takes AGES.

If Not (cmd Is Nothing) Then
cmd.Parameters("symbol").Value = strSymbol
Set rs = cmd.Execute
rs.MoveFirst
Debug.Print rs!Symbol
rs.Close
End If

Set cmd = Nothing

This is exactly the code I want to use -= but i have tried other ways of running the query in code (Set oRS = oConn.Execute(strSQL)) but it still runs VERY slowly although it does return the expected results.

Help!!


Stew
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top