Best way to connect?

vidyajayakar

Member
Joined
Jul 25, 2005
Messages
5
Location
Boulder, CO
Programming Experience
Beginner
[RESOLVED] Best way to connect?

I'm using OleDb to connect to an Access Database. I have several controls on my form, and most of the controls are populated based on the values chosen by the user in the previous controls.
Now, is it a good idea to store the connection information as global variables (shared variables) and connect to the database only when necessary, or should I maintain the database connection throughout the life of the form? Is there any significant advantage of one of the methods over the other?

I'm a newbie, and any thoughts on this will be appreciated.
Thanks!
 
Last edited:
It is not a bad idea to have a single OleDbConnection object to use everywhere throughout your app, but it is not a good idea to keep it open all the time. I suggest using a single connection but only Open and Close it as needed.
 
Back
Top