Solved

Database Connection

Posted on 2014-09-09
4
165 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
ID: 40313248
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
ID: 40313253
Thanks Jerry....
0
 
LVL 18

Expert Comment

by:Jerry Miller
ID: 40313255
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
ID: 40313260
I will look into those. Thanks... Reading the article now...
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

929 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

5 Experts available now in Live!

Get 1:1 Help Now