VBA New Database Connection
TL;DR How to change the code below to prevent what you see in the screenshot.
I am running a macro with the following code
' this is ctreating multiple connections.
Set rec1 = New ADODB.Recordset
rec1.Open thisSql, conn
which runs a SQL Server query (which is around 20 lines long and contains
4 joins). Everything is fine except for the fact that after a couple times
of running it my DB admin says that my query is loading up the DB too
much.
Now, my query could be causing the problem, or it could be that Excel is
starting to run multiple connections at once. Some evidence for this is
the screenshot below and the fact that the load on the database appears to
increase with time.
How do I establish a DB connection without constantly creating new
connections?
Has anyone had similar problems working with Excel DB macros?
No comments:
Post a Comment