Solved

Database Connection

Posted on 2014-09-09
4
163 Views
Last Modified: 2014-09-09
Experts, just a quick question. I am about to start work on an application and was just wondering about good practices. I will use an Access database with my application. The question I have with regards to the connection should I open the connection in a module and make it public so that all forms and classes can access it and then close the connection when the application closes? Or should I create the connection within each form or class and then close the connection with the form is closed or the class is disposed of? Or does it make any difference.
0
Comment
Question by:Basicfarmer
  • 2
  • 2
4 Comments
 
LVL 18

Accepted Solution

by:
Jerry Miller earned 500 total points
Comment Utility
From the .Net side, you should normally only keep the connection open while you are accessing it and close it when that operation is complete. Databases only have a limited number of connections and each query would use it's own connection and you would quickly no longer be able to connect from the application.

See this about ADO.net connections, they use an Access database. It should help you. Please don't be offended by the title, it was simply a good read.

http://www.codeproject.com/Articles/8477/Using-ADO-NET-for-beginners
0
 

Author Closing Comment

by:Basicfarmer
Comment Utility
Thanks Jerry....
0
 
LVL 18

Expert Comment

by:Jerry Miller
Comment Utility
But if you are building an application that is going to get much use or needs to grow in the future, I would look at using a database and not Access. It is good for single user, low data type apps, but anything that needs to hold more than 1 or 2GB needs to be somewhere else (MS SQL, MY SQL, Oracle, etc.)
0
 

Author Comment

by:Basicfarmer
Comment Utility
I will look into those. Thanks... Reading the article now...
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
Having just graduated from college and entered the workforce, I don’t find myself always using the tools and programs I grew accustomed to over the past four years. However, there is one program I continually find myself reverting back to…R.   So …
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now