我正在使用Visual Studio 2012 Ultimate(带有所有服务包)、C#和.NET Framework 4.5开发WinForm应用程序。
我遇到了以下异常:
Internal .Net Framework Data Provider error 1
使用这个技术栈:
en System.Data.ProviderBase.DbConnectionInternal.PrePush(Object expectedOwner)
en System.Data.ProviderBase.DbConnectionPool.PutObject(DbConnectionInternal obj, Object owningObject)
en System.Data.ProviderBase.DbConnectionInternal.CloseConnection(DbConnection owningObject, DbConnectionFactory connectionFactory)
en System.Data.SqlClient.SqlConnection.CloseInnerConnection()
en System.Data.SqlClient.SqlConnection.Close()
en AdoData.TRZIC.DisposeCurrentConnection()
en AdoData.TRZIC.Finalize()
在析构函数中:
~TRZIC()
{
DisposeCurrentConnection();
if (this.getCodeCmd != null)
this.getCodeCmd.Dispose();
}
private void DisposeCurrentConnection()
{
if (this.conn != null)
{
if (this.conn.State == ConnectionState.Open)
this.conn.Close();
this.conn.Dispose();
this.conn = null;
}
}
我在this.conn.Close();
这一行遇到了异常。
conn
是一个private SqlConnection conn = null;
。
你知道为什么会出现这种情况吗?
this.conn=null;
,我建议在调用DisposeCurrentConnection()
之前先处理你的命令。 - Reza