Internal .Net Framework Data Provider error 1

Discussion in 'ASP .Net' started by Andrew, Apr 7, 2006.

  1. Andrew

    Andrew Guest

    Win2k3
    IIS6
    ..NET 2.0

    In my ASP.NET 2.0 app I create an open an SQL connection in the page's
    constructor and call objSQL.Dispose() in the destructor. The SQLConnection
    object is a class member of the page. Here's the destructor code:

    /// Destructor
    ~Officer()
    {
    if( m_objConn != null )
    m_objConn.Dispose();
    }
    /// End Destructor


    When running this particular page through some testing I get the following
    exception in the destructor at the "m_objConn.Dispose();" line:

    System.InvalidOperationException was unhandled
    Message="Internal .Net Framework Data Provider error 1."
    Source="System.Data"
    StackTrace:
    at System.Data.ProviderBase.DbConnectionInternal.PrePush(Object
    expectedOwner)
    at
    System.Data.ProviderBase.DbConnectionPool.PutObject(DbConnectionInternal
    obj, Object owningObject)
    at
    System.Data.ProviderBase.DbConnectionInternal.CloseConnection(DbConnection
    owningObject, DbConnectionFactory connectionFactory)
    at System.Data.SqlClient.SqlConnection.Close()
    at System.Data.SqlClient.SqlConnection.Dispose(Boolean disposing)
    at System.ComponentModel.Component.Dispose()
    at Officer.Finalize() in c:\sys\projects\AddOfficer.aspx.cs:line 46

    When I stop debugging VS2k5 pops up the JIT debugging dialog stating an
    unhandled exception occurred in w3wp.exe.

    1) Is this a bug?
    2) Do I need a try/catch in a destructor? Is it good programming practice?
    3) Why is this happening?
    4) What is the meaning of life?


    Any help is appreciated. TIA

    Andrew
    Andrew, Apr 7, 2006
    #1
    1. Advertising

  2. Andrew

    Jeff Dillon Guest

    You should never hold onto a connection for the life of a page. Open and
    close the connection each time you need to. Let Connection Pooling work for
    you.

    Jeff

    "Andrew" <andrew_test(dont spam its not cool)@hotmail.com> wrote in message
    news:%...
    > Win2k3
    > IIS6
    > .NET 2.0
    >
    > In my ASP.NET 2.0 app I create an open an SQL connection in the page's
    > constructor and call objSQL.Dispose() in the destructor. The
    > SQLConnection object is a class member of the page. Here's the destructor
    > code:
    >
    > /// Destructor
    > ~Officer()
    > {
    > if( m_objConn != null )
    > m_objConn.Dispose();
    > }
    > /// End Destructor
    >
    >
    > When running this particular page through some testing I get the following
    > exception in the destructor at the "m_objConn.Dispose();" line:
    >
    > System.InvalidOperationException was unhandled
    > Message="Internal .Net Framework Data Provider error 1."
    > Source="System.Data"
    > StackTrace:
    > at System.Data.ProviderBase.DbConnectionInternal.PrePush(Object
    > expectedOwner)
    > at
    > System.Data.ProviderBase.DbConnectionPool.PutObject(DbConnectionInternal
    > obj, Object owningObject)
    > at
    > System.Data.ProviderBase.DbConnectionInternal.CloseConnection(DbConnection
    > owningObject, DbConnectionFactory connectionFactory)
    > at System.Data.SqlClient.SqlConnection.Close()
    > at System.Data.SqlClient.SqlConnection.Dispose(Boolean disposing)
    > at System.ComponentModel.Component.Dispose()
    > at Officer.Finalize() in c:\sys\projects\AddOfficer.aspx.cs:line 46
    >
    > When I stop debugging VS2k5 pops up the JIT debugging dialog stating an
    > unhandled exception occurred in w3wp.exe.
    >
    > 1) Is this a bug?
    > 2) Do I need a try/catch in a destructor? Is it good programming
    > practice?
    > 3) Why is this happening?
    > 4) What is the meaning of life?
    >
    >
    > Any help is appreciated. TIA
    >
    > Andrew
    >
    >
    Jeff Dillon, Apr 7, 2006
    #2
    1. Advertising

  3. Andrew

    Andrew Guest

    Thanks for the connection pooling tip. However in this case I'm not sure
    how it's relevant. More detail on the cause of the error and whether
    destructors should have exception handling code would be helpful.

    Thanks,
    Andrew

    "Jeff Dillon" <> wrote in message
    news:...
    > You should never hold onto a connection for the life of a page. Open and
    > close the connection each time you need to. Let Connection Pooling work
    > for you.
    >
    > Jeff
    >
    > "Andrew" <andrew_test(dont spam its not cool)@hotmail.com> wrote in
    > message news:%...
    >> Win2k3
    >> IIS6
    >> .NET 2.0
    >>
    >> In my ASP.NET 2.0 app I create an open an SQL connection in the page's
    >> constructor and call objSQL.Dispose() in the destructor. The
    >> SQLConnection object is a class member of the page. Here's the
    >> destructor code:
    >>
    >> /// Destructor
    >> ~Officer()
    >> {
    >> if( m_objConn != null )
    >> m_objConn.Dispose();
    >> }
    >> /// End Destructor
    >>
    >>
    >> When running this particular page through some testing I get the
    >> following exception in the destructor at the "m_objConn.Dispose();" line:
    >>
    >> System.InvalidOperationException was unhandled
    >> Message="Internal .Net Framework Data Provider error 1."
    >> Source="System.Data"
    >> StackTrace:
    >> at System.Data.ProviderBase.DbConnectionInternal.PrePush(Object
    >> expectedOwner)
    >> at
    >> System.Data.ProviderBase.DbConnectionPool.PutObject(DbConnectionInternal
    >> obj, Object owningObject)
    >> at
    >> System.Data.ProviderBase.DbConnectionInternal.CloseConnection(DbConnection
    >> owningObject, DbConnectionFactory connectionFactory)
    >> at System.Data.SqlClient.SqlConnection.Close()
    >> at System.Data.SqlClient.SqlConnection.Dispose(Boolean disposing)
    >> at System.ComponentModel.Component.Dispose()
    >> at Officer.Finalize() in c:\sys\projects\AddOfficer.aspx.cs:line 46
    >>
    >> When I stop debugging VS2k5 pops up the JIT debugging dialog stating an
    >> unhandled exception occurred in w3wp.exe.
    >>
    >> 1) Is this a bug?
    >> 2) Do I need a try/catch in a destructor? Is it good programming
    >> practice?
    >> 3) Why is this happening?
    >> 4) What is the meaning of life?
    >>
    >>
    >> Any help is appreciated. TIA
    >>
    >> Andrew
    >>
    >>

    >
    >
    Andrew, Apr 8, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. BS
    Replies:
    3
    Views:
    2,044
    Alvin Bruney [MVP]
    Jun 17, 2004
  2. Doug
    Replies:
    2
    Views:
    616
  3. sloan
    Replies:
    5
    Views:
    1,497
    sloan
    Jun 4, 2006
  4. sloan
    Replies:
    1
    Views:
    500
    Chad Scharf
    Jul 3, 2007
  5. Spam Catcher
    Replies:
    4
    Views:
    464
    John Saunders [MVP]
    Jul 6, 2007
Loading...

Share This Page