Handling connections to MS Access database

Last post 06-26-2009 7:07 PM by mbanavige. 1 replies.

Sort Posts:

  • Handling connections to MS Access database

    06-26-2009, 6:26 PM
    • Member
      6 point Member
    • AnnaMaria
    • Member since 06-18-2009, 10:51 AM
    • Posts 13

    Hallo,

    I'm developing a web interface to a MS Access database with ASP.NET 3.5. There are about 10 users. I guess that each of them will have a look into the database 20 times per day and will add about 20 new records per day. 

    Now I'm thinking about the best way to handle the connections to the database. 

    Keeping a single connection during the whole session does not seem to be a good idea as a session might last a whole day.

    But is it ok to open a new connection for each SQL command?

    Is there any other possibility?

    Thanks in advance,

    Anna



  • Re: Handling connections to MS Access database

    06-26-2009, 7:07 PM
    Answer
    • All-Star
      97,456 point All-Star
    • mbanavige
    • Member since 11-06-2003, 1:29 PM
    • New England, USA
    • Posts 10,297
    • Moderator
      TrustedFriends-MVPs

    The technique that is generally preferred is to:

    1. Open the db connection as late as possible
    2. Close that db connection as soon as possible

    This means, do not open your db connection until you are ready to execute a statement against the db and then immediately after accessing your db, you would want to close that connection. 

    AnnaMaria:
    But is it ok to open a new connection for each SQL command?

    Yes - .NET will handle connection pooling for you so that performance won't suffer.

    Mike Banavige
    ~~~~~~~~~~~~
    Need a site code sample in a different language? Try converting it with: http://converter.telerik.com/
Page 1 of 1 (2 items)