Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connection Pooling with Access database

I have an application which reads data from an Access databse frequently, is there any way to use connection pooling?

My Open Databse method:-

private bool OpenDatabaseConnection(string databaseName)
{
    try
    {
        string connectionString = "Provider = Microsoft.Jet.OLEDB.4.0; " +
            "Data Source = " + databaseName + ";";
        settingsDbConn = new OleDbConnection(connectionString);
        settingsDbConn.Open();
    }
    catch (Exception)
    {
        return false;
    }

    return true;
}
like image 1000
NIlesh Lanke Avatar asked Apr 04 '12 13:04

NIlesh Lanke


1 Answers

I concur with the comment of @sll but, to answer your question, then add this string to your connection string

OLE DB Services=-1

This will force the connection pooling with JET OleDB provider.
However test the performance of your app with and without this setting.
The difference should be negligible. And, with this setting, rembember to ALWAYS return the connection to the connection pool closing it with con.Close or encapsulating your connection in a using statement.

Looking at your code above I will be very careful.

like image 108
Steve Avatar answered Sep 23 '22 20:09

Steve