Solved

Database Connection

Posted on 2014-09-09
4
170 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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 goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…

707 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