问题
I have a problem with a OleDbConnection accessing a .mdb File on a Windows share in the same network. When it gets disposed at the end of the using part, it needs more than 2 seconds for that. Opening the connection and executing the query or filling the DataTable only needs up to 50ms.
that's my code:
private const string DbStConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;data source=\\master\db\datenezpz2004\dbST.mdb";
private const string DbStConnectionStringIp = @"Provider=Microsoft.ACE.OLEDB.12.0;data source=\\192.168.254.10\db\datenezpz2004\dbST.mdb";
using(var connection = new OleDbConnection())
{
//Die richtige Verbindungszueichenfolge finden
connection.ConnectionString = DbStConnectionString;
try
{
connection.Open();
}
catch(OleDbException)
{
connection.ConnectionString = DbStConnectionStringIp;
connection.Open();
}
//Command ausführen
const string query = "SELECT ST.idst, FName FROM ST WHERE (((ST.Status) = True) AND ((ST.IDArt) = 11))"; // AND ((ST.Fname) LIKE '%{username}%');";
using(var command = new OleDbCommand(query, connection))
{
using(var adapter = new OleDbDataAdapter(command))
{
adapter.Fill(employees);
}
}
//From Here
}
//To Here => 2 seconds
Basically "From Here " to "To Here" is the most time consuming part of the Code. Do you have an Idea, why it's so slow?
来源:https://stackoverflow.com/questions/37206430/oledbconnection-dispose-very-slow-2s