Solved

Database Connection

Posted on 2014-09-09
4
167 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

If you haven’t already, I encourage you to read the first article (http://www.experts-exchange.com/articles/18680/An-Introduction-to-R-Programming-and-R-Studio.html) in my series to gain a basic foundation of R and R Studio.  You will also find the …
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

790 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