我在C#中使用访问数据库。
我有一个名为MdbLibrary的辅助类。
在我的应用程序中,多线程调用打开和关闭。
它在下面给出了错误:
An attempt has been made to free an RCW that is in use. The RCW is in use on the active thread or another thread. Attempting to free an in-use RCW can cause corruption or data loss.
关闭连接时总会发生这种情况。
private OleDbConnection _Conn = null;
public void Open(string _strConnectionString)
{
_Conn = new OleDbConnection(_strConnectionString);
_Conn.Open();
_Command = new OleDbCommand();
_Command.Connection = _Conn;
if (this.ConnectionTimeOut != 30)
_Command.CommandTimeout = this.ConnectionTimeOut;
}
public void Close()
{
_Conn.Close(); --> here i get an error.
}
有什么想法解决这个问题吗?