Strange problem with CDaoRecordset
-
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
-
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
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.
-
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.
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
-
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
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.
-
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.
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 -
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. MSSorry 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.