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;
}
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With