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 problem with CDaoRecordset

Strange problem with CDaoRecordset

Scheduled Pinned Locked Moved C / C++ / MFC
helpc++securitydebuggingquestion
6 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.
  • M Offline
    M Offline
    Manfred Staiger
    wrote on last edited by
    #1

    Since some days the debug build of my application crashes when calling the close() and requery() members of CDaoRecordset and when deleting all recorsets of a table in a loop, the call of delete for the last recordset crashes. Stepping into the MFC code shows that it always occurs at the same place in some code for the DFX mechanism. Since it's the same problem on all my three machines and it appeared "over night", I don't think that it is a bug in MFC. The only changes on all three machines are several service packs/security patches applied from our pc-support guys, so I think the problem is within the MS JetEngine which perhaps was affected by applied patches. So what would you do now ??? MS

    S 1 Reply Last reply
    0
    • M Manfred Staiger

      Since some days the debug build of my application crashes when calling the close() and requery() members of CDaoRecordset and when deleting all recorsets of a table in a loop, the call of delete for the last recordset crashes. Stepping into the MFC code shows that it always occurs at the same place in some code for the DFX mechanism. Since it's the same problem on all my three machines and it appeared "over night", I don't think that it is a bug in MFC. The only changes on all three machines are several service packs/security patches applied from our pc-support guys, so I think the problem is within the MS JetEngine which perhaps was affected by applied patches. So what would you do now ??? MS

      S Offline
      S Offline
      S Douglas
      wrote on last edited by
      #2

      Manfred Staiger wrote: Since some days the debug build of my application crashes when calling the close() and requery() members of CDaoRecordset and when deleting all recorsets of a table in a loop, the call of delete for the last recordset crashes. Stepping into the MFC code shows that it always occurs at the same place in some code for the DFX mechanism. Since it's the same problem on all my three machines and it appeared "over night", I don't think that it is a bug in MFC. The only changes on all three machines are several service packs/security patches applied from our pc-support guys, so I think the problem is within the MS JetEngine which perhaps was affected by applied patches. So what would you do now ??? 1: All Database operations should be enclosed in try catch statements. There are a number of reasons why a data connection could fail and cause your app to crash. For starters make sure its still open before attempting to close it. 2: Why loop through an entire table to delete all of the records? A Delete query is much faster. 3: What versions of jet where you using? What versions are you using now? Social Engineering Specialist. Because there is no patch for human stupidity.

      M 1 Reply Last reply
      0
      • S S Douglas

        Manfred Staiger wrote: Since some days the debug build of my application crashes when calling the close() and requery() members of CDaoRecordset and when deleting all recorsets of a table in a loop, the call of delete for the last recordset crashes. Stepping into the MFC code shows that it always occurs at the same place in some code for the DFX mechanism. Since it's the same problem on all my three machines and it appeared "over night", I don't think that it is a bug in MFC. The only changes on all three machines are several service packs/security patches applied from our pc-support guys, so I think the problem is within the MS JetEngine which perhaps was affected by applied patches. So what would you do now ??? 1: All Database operations should be enclosed in try catch statements. There are a number of reasons why a data connection could fail and cause your app to crash. For starters make sure its still open before attempting to close it. 2: Why loop through an entire table to delete all of the records? A Delete query is much faster. 3: What versions of jet where you using? What versions are you using now? Social Engineering Specialist. Because there is no patch for human stupidity.

        M Offline
        M Offline
        Manfred Staiger
        wrote on last edited by
        #3

        sfdougl wrote: 1: All Database operations should be enclosed in try catch statements. There are a number of reasons why a data connection could fail and cause your app to crash. For starters make sure its still open before attempting to close it. That's right, but doesn't solve my problem. sfdougl wrote: 2: Why loop through an entire table to delete all of the records? A Delete query is much faster. Of course I don't loop the entire table to delete the recordsets. I only wanted to describe that the Delete() call crashes at the last recordset when you do so. sfdougl wrote: 3: What versions of jet where you using? What versions are you using now? Unfortunately I don't remember if it has changed. I'm now looking for a PC with an older jet version as the one I have on my machine. MS

        S 1 Reply Last reply
        0
        • M Manfred Staiger

          sfdougl wrote: 1: All Database operations should be enclosed in try catch statements. There are a number of reasons why a data connection could fail and cause your app to crash. For starters make sure its still open before attempting to close it. That's right, but doesn't solve my problem. sfdougl wrote: 2: Why loop through an entire table to delete all of the records? A Delete query is much faster. Of course I don't loop the entire table to delete the recordsets. I only wanted to describe that the Delete() call crashes at the last recordset when you do so. sfdougl wrote: 3: What versions of jet where you using? What versions are you using now? Unfortunately I don't remember if it has changed. I'm now looking for a PC with an older jet version as the one I have on my machine. MS

          S Offline
          S Offline
          S Douglas
          wrote on last edited by
          #4

          1: Okay, so what specific error are you receiving? 2: Are you making sure that you have not gone past EOF? Or attempting to delete a record that does not exist? Source Code and Errors received would greatly expedite the process. Social Engineering Specialist. Because there is no patch for human stupidity.

          M 1 Reply Last reply
          0
          • S S Douglas

            1: Okay, so what specific error are you receiving? 2: Are you making sure that you have not gone past EOF? Or attempting to delete a record that does not exist? Source Code and Errors received would greatly expedite the process. Social Engineering Specialist. Because there is no patch for human stupidity.

            M Offline
            M Offline
            Manfred Staiger
            wrote on last edited by
            #5

            sfdougl wrote: 1: Okay, so what specific error are you receiving? There is no exception thrown. A dialog comes up saying "User breakpoint called from code at 0x778813b1". The output window of the editor shows the following messages: HEAP[TestApp_g.exe]: Heap block at 038C8940 modified at 038C8998 past requested size of 50 sfdougl wrote: 2: Are you making sure that you have not gone past EOF? Or attempting to delete a record that does not exist? Yes, absolutely. Everything worked fine for more than 2 years and when I make a release build it also works fine. I made a small example which crashes as described, and works fine as release build. //CTestClass is derived from CDaoRecordset //m_nDefaultType member is set to dbOpenDynaset in the constructor //m_pDatabase member is set to an open database (which contains the table "TestTable") void CTestClass::DeleteWithLoop() { int counter=0; this->Open(AFX_DAO_USE_DEFAULT_TYPE, "TestTable", 0); if(!this->IsEOF()) { while(!this->IsEOF()) { counter++; this->Delete(); //crash at last recordset this->MoveNext(); } } this->Close(); } In the meantime I'm quite shure that it's a bug in the jet engine. MS

            S 1 Reply Last reply
            0
            • M Manfred Staiger

              sfdougl wrote: 1: Okay, so what specific error are you receiving? There is no exception thrown. A dialog comes up saying "User breakpoint called from code at 0x778813b1". The output window of the editor shows the following messages: HEAP[TestApp_g.exe]: Heap block at 038C8940 modified at 038C8998 past requested size of 50 sfdougl wrote: 2: Are you making sure that you have not gone past EOF? Or attempting to delete a record that does not exist? Yes, absolutely. Everything worked fine for more than 2 years and when I make a release build it also works fine. I made a small example which crashes as described, and works fine as release build. //CTestClass is derived from CDaoRecordset //m_nDefaultType member is set to dbOpenDynaset in the constructor //m_pDatabase member is set to an open database (which contains the table "TestTable") void CTestClass::DeleteWithLoop() { int counter=0; this->Open(AFX_DAO_USE_DEFAULT_TYPE, "TestTable", 0); if(!this->IsEOF()) { while(!this->IsEOF()) { counter++; this->Delete(); //crash at last recordset this->MoveNext(); } } this->Close(); } In the meantime I'm quite shure that it's a bug in the jet engine. MS

              S Offline
              S Offline
              S Douglas
              wrote on last edited by
              #6

              Sorry it took so long for me to get back to you. I'm on an odd schedule. 1: Good question, I don’t have a clue here. 2: The problem most probably isn't the delete statement but the MoveNext() if you delete the last record and attempted to move to a record that doesn’t exist an error occurs. I have had the same problem. Perhaps, the newer DAO version is stricter about such operations. When you get a chance can you find out what version of DAO your using? Have any workstations that where not updated? Social Engineering Specialist. Because there is no patch for human stupidity.

              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