Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Strange error in CDatabase::Close()???

Strange error in CDatabase::Close()???

Scheduled Pinned Locked Moved C / C++ / MFC
helpdatabasedebuggingquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Arrin
    wrote on last edited by
    #1

    Hi, if i debug my application, and want to close them, i receive sometimes this strange error in

    // Disconnect connection
    void CDatabase::Close()
    {
    ASSERT_VALID(this);

    // Close any open recordsets
    AfxLockGlobals(CRIT\_ODBC);
    TRY
    {
    	while (!m\_listRecordsets.IsEmpty())
    	{
    		CRecordset\* pSet = (CRecordset\*)m\_listRecordsets.GetHead();
    		pSet->Close();  // will implicitly remove from list
    		pSet->m\_pDatabase = NULL;
    	}
    }
    CATCH\_ALL(e)
    {
    	AfxUnlockGlobals(CRIT\_ODBC);
    	THROW\_LAST();
    }
    END\_CATCH\_ALL
    AfxUnlockGlobals(CRIT\_ODBC);
    
    if (m\_hdbc != SQL\_NULL\_HDBC)
    {
    	RETCODE nRetCode;
    	AFX\_SQL\_SYNC(::SQLDisconnect(m\_hdbc)); **// here is error???**
    	AFX\_SQL\_SYNC(::SQLFreeConnect(m\_hdbc));
    	m\_hdbc = SQL\_NULL\_HDBC;
    
    	\_AFX\_DB\_STATE\* pDbState = \_afxDbState;
    
    	AfxLockGlobals(CRIT\_ODBC);
    	ASSERT(pDbState->m\_nAllocatedConnections != 0);
    	pDbState->m\_nAllocatedConnections--;
    	AfxUnlockGlobals(CRIT\_ODBC);
    }
    

    }

    But the best is i dont habe any kind of database in my project included???? Does any one have a answer for this issue??? thanks for any help! Arrin

    _ 1 Reply Last reply
    0
    • A Arrin

      Hi, if i debug my application, and want to close them, i receive sometimes this strange error in

      // Disconnect connection
      void CDatabase::Close()
      {
      ASSERT_VALID(this);

      // Close any open recordsets
      AfxLockGlobals(CRIT\_ODBC);
      TRY
      {
      	while (!m\_listRecordsets.IsEmpty())
      	{
      		CRecordset\* pSet = (CRecordset\*)m\_listRecordsets.GetHead();
      		pSet->Close();  // will implicitly remove from list
      		pSet->m\_pDatabase = NULL;
      	}
      }
      CATCH\_ALL(e)
      {
      	AfxUnlockGlobals(CRIT\_ODBC);
      	THROW\_LAST();
      }
      END\_CATCH\_ALL
      AfxUnlockGlobals(CRIT\_ODBC);
      
      if (m\_hdbc != SQL\_NULL\_HDBC)
      {
      	RETCODE nRetCode;
      	AFX\_SQL\_SYNC(::SQLDisconnect(m\_hdbc)); **// here is error???**
      	AFX\_SQL\_SYNC(::SQLFreeConnect(m\_hdbc));
      	m\_hdbc = SQL\_NULL\_HDBC;
      
      	\_AFX\_DB\_STATE\* pDbState = \_afxDbState;
      
      	AfxLockGlobals(CRIT\_ODBC);
      	ASSERT(pDbState->m\_nAllocatedConnections != 0);
      	pDbState->m\_nAllocatedConnections--;
      	AfxUnlockGlobals(CRIT\_ODBC);
      }
      

      }

      But the best is i dont habe any kind of database in my project included???? Does any one have a answer for this issue??? thanks for any help! Arrin

      _ Offline
      _ Offline
      _Superman_
      wrote on last edited by
      #2

      Look at the call stack and you can figure out the sequence of functions that are being called. From this you can understand how the control reached that particular function.

      «_Superman_» I love work. It gives me something to do between weekends.

      A 1 Reply Last reply
      0
      • _ _Superman_

        Look at the call stack and you can figure out the sequence of functions that are being called. From this you can understand how the control reached that particular function.

        «_Superman_» I love work. It gives me something to do between weekends.

        A Offline
        A Offline
        Arrin
        wrote on last edited by
        #3

        Hi, thanks for answer!! arrin

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups