Tôi đang phát triển một ứng dụng WinForm với Visual Studio 2012 Phiên bản cuối cùng với tất cả gói dịch vụ, C# và Khuôn khổ .NET 4.5.Lỗi Nhà cung cấp Dữ liệu Khung Nội bộ 1
tôi nhận được ngoại lệ này:
Internal .Net Framework Data Provider error 1
Với đống này:
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()
Trong destructor:
~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;
}
}
tôi nhận được ngoại lệ trong dòng this.conn.Close();
.
Và conn
là private SqlConnection conn = null;
Bạn có biết tại sao?
Có một số sai lầm, bạn không cần phải 'this.conn = null; 'sau khi xử lý nó, và tôi cũng khuyên bạn nên vứt bỏ lệnh của bạn trước khi gọi' DisposeCurrentConnection() ' – RezaRahmati