CRecordset Access Violation 
Author Message
 CRecordset Access Violation

Please help.

We get the following exception:

 0x0000005 Access violation in ODBCCR32.DLL
when we attempt to close a recordset (that we
ensure is open).

This is with VC++ V5 under NT 4.0 (using Oracle 7 or 8).

It appears that the m_hstmt value is invalid
when the call to SQLFreeStmt is called, causing the access violation.

Thanks for any help!  
john

void CRecordset::Close()
{
        ASSERT_VALID(this);
.
.
.
.
        RETCODE nRetCode;
        if (m_hstmt != SQL_NULL_HSTMT)
        {
                AFX_SQL_SYNC(::SQLFreeStmt(m_hstmt, SQL_DROP));
                m_hstmt = SQL_NULL_HSTMT;
        }



Sat, 14 Oct 2000 03:00:00 GMT  
 CRecordset Access Violation

This may not be your issue:  I used to get access violations if I created
the CDatabase and CRecordset in the same scope.  When the CRecordset
destructor was called, the CDatabase object may have already been deleted
or invalid.
I usually create CDatabase as a pointer member variable outside of the
method where the CRecordset was created and destroyed.

Quote:

> Please help.

> We get the following exception:

>  0x0000005 Access violation in ODBCCR32.DLL
> when we attempt to close a recordset (that we
> ensure is open).

> This is with VC++ V5 under NT 4.0 (using Oracle 7 or 8).

> It appears that the m_hstmt value is invalid
> when the call to SQLFreeStmt is called, causing the access violation.

> Thanks for any help!
> john

> void CRecordset::Close()
> {
>         ASSERT_VALID(this);
> .
> .
> .
> .
>         RETCODE nRetCode;
>         if (m_hstmt != SQL_NULL_HSTMT)
>         {
>                 AFX_SQL_SYNC(::SQLFreeStmt(m_hstmt, SQL_DROP));
>                 m_hstmt = SQL_NULL_HSTMT;
>         }



Sun, 15 Oct 2000 03:00:00 GMT  
 CRecordset Access Violation

I don't think this applies.  We are not destroying either the CRecordset
or the CDatabase.  We are simply trying to close the CRecordset.  Any
other suggestions?
Thanks.
-john

Quote:

> This may not be your issue:  I used to get access violations if I created
> the CDatabase and CRecordset in the same scope.  When the CRecordset
> destructor was called, the CDatabase object may have already been deleted
> or invalid.
> I usually create CDatabase as a pointer member variable outside of the
> method where the CRecordset was created and destroyed.


> > Please help.

> > We get the following exception:

> >  0x0000005 Access violation in ODBCCR32.DLL
> > when we attempt to close a recordset (that we
> > ensure is open).

> > This is with VC++ V5 under NT 4.0 (using Oracle 7 or 8).

> > It appears that the m_hstmt value is invalid
> > when the call to SQLFreeStmt is called, causing the access violation.

> > Thanks for any help!
> > john

> > void CRecordset::Close()
> > {
> >         ASSERT_VALID(this);
> > .
> > .
> > .
> > .
> >         RETCODE nRetCode;
> >         if (m_hstmt != SQL_NULL_HSTMT)
> >         {
> >                 AFX_SQL_SYNC(::SQLFreeStmt(m_hstmt, SQL_DROP));
> >                 m_hstmt = SQL_NULL_HSTMT;
> >         }



Mon, 16 Oct 2000 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. CRecordset - access violations

2. CRecordset access violation

3. Access Violation when calling CRecordset::Requery()

4. NTDLL.DLL Access Violation in CRecordset-derived class?

5. Access violations once OCBC/CRecordset added to console app

6. CRecordset Open Access violation

7. Access violation in CRecordset.Close()

8. Memory access violation using CRecordset and date/time fields

9. Access Violation when calling CRecordset::Requery()

10. "Access violation" accessing a DLL

11. URGENT: Access Violation when accessing the POOM IAppointment

12. access violation in

 

 
Powered by phpBB® Forum Software