OleDbConnection Dispose very slow (2s)

a 夏天 提交于 2019-12-01 20:59:57

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!