Database connection in VBA

fdmaxey

New Member
Joined
Mar 4, 2019
Messages
3
Newbie question: In a project with a number of subroutines and functions that query and update a database, is there an advantage (or disadvantage) to having just one global database connection that is opened upon initialization of the project and stays open until the project is closed?
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
The advantage is that the code might run somewhat faster. The disadvantage is it might lose the connection so the code becomes more complex as you need to validate the connection each time you use it and restore it if it has been lost.

You might consider using Power Query to import and transform your data. I haven't used VBA queries since I started using PQ. It' relatively easy to learn (easier than VBA).
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,606
Messages
6,120,492
Members
448,967
Latest member
visheshkotha

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top