Debug assertion using CRecordset.
Ronen Ashkenazi -- rashken@ms-israel.kla.com Thursday, September 12, 1996 Enviroment: x86,NT 3.51,VC4.1 Hi, I have a CRecordset inherited object that's used to connect to my database through ODBC. When I created the CRecordset using class wizard I could connect to the database and everything worked just fine. I then had to delete a column from the database and made the necessary changes in my recordset. This included: 1. Removing the member variable representing that database column (.h file). 2. Removing the appropriate AFX_FIELD_MAP line (.cpp file). Now when I try to connect to the database using code that previously worked I get an Assertion failure: Debug Assertion Failed! Program ...... File: dbcore.cpp Line:2578 This assertion happens when I try to open the set. I do get the DBMS login dialog and after I log in (supply the password) the assertion happens. When I tried to debug this I saw that the assertion is a result of issuing the MoveFirst() command after opening the set. Apparently the set remains closed. Am I missing something ? Where else should the code be changed to reflect the changes in the database columns ? Thanks in advance, Ronen Ashkenazi.
Dean Wiles -- deanw@isc-br.isc-br.com Friday, September 13, 1996 [Mini-digest: 2 responses] You also need to decrement the field count (m_nFields) in the AFX_FIELD_INIT section of your recordset constructor: At 06:09 PM 9/12/96 PDT, you wrote: > >Enviroment: x86,NT 3.51,VC4.1 > >Hi, > >I have a CRecordset inherited object that's used to connect to my >database through ODBC. When I created the CRecordset using class wizard I >could connect to the database and everything worked just fine. > I then had to delete a column from the database and made the necessary >changes in my recordset. This included: >1. Removing the member variable representing that database column (.h >file). >2. Removing the appropriate AFX_FIELD_MAP line (.cpp file). > >Now when I try to connect to the database using code that previously >worked I get an Assertion failure: > >Debug Assertion Failed! >Program ...... >File: dbcore.cpp >Line:2578 > >This assertion happens when I try to open the set. I do get the DBMS >login dialog and after I log in (supply the password) the assertion >happens. When I tried to debug this I saw that the assertion is a result >of issuing the MoveFirst() command after opening the set. Apparently the >set remains closed. > Am I missing something ? > Where else should the code be changed to reflect the changes in the >database columns ? > >Thanks in advance, >Ronen Ashkenazi. > > > -------------------------------------------------------------------------- Dean Wiles (deanw@mail.isc-br.com) Olivetti North America Phone: (509)927-7037 22425 East Appleway Ave Fax: (509)927-2499 Liberty Lake, WA 99019-9534 If the Son sets you free, you will be free indeed. (John 8:36) -----From: Geoffrey NichollsThis may very well be a mismatch on the m_nFields member. This is the way I did it in my constructor of a CRecordset class, so that I wouldn't have this problem: m_nFields = 0; //{{AFX_FIELD_INIT(CAddressSet) m_strAddressID = _T(""); m_nFields++; m_strContactID = _T(""); m_nFields++; m_strType = _T(""); m_nFields++; m_strLine1 = _T(""); m_nFields++; m_strLine2 = _T(""); m_nFields++; m_strCity = _T(""); m_nFields++; m_strState = _T(""); m_nFields++; m_strZip = _T(""); m_nFields++; m_strCountry = _T(""); m_nFields++; m_strSalutation = _T(""); m_nFields++; m_strSuffix = _T(""); m_nFields++; m_strDear = _T(""); m_nFields++; //}}AFX_FIELD_INIT -------------------------------------- Geoffrey Nicholls Gazelle Software 415/323-5545 (voice) 415/323-1913 (fax) http://www.gazelle.com 667 Marion Ave Palo Alto, CA, 94301 --------------------------------------
Mike Blaszczak -- mikeblas@nwlink.com Friday, September 13, 1996 [Mini-digest: 2 responses] At 06:09 PM 9/12/96 PDT, Ronen Ashkenazi wrote: >Enviroment: x86,NT 3.51,VC4.1 >I have a CRecordset inherited object that's used to connect to my >database through ODBC. When I created the CRecordset using class wizard I >could connect to the database and everything worked just fine. > I then had to delete a column from the database and made the necessary >changes in my recordset. This included: >1. Removing the member variable representing that database column (.h >file). >2. Removing the appropriate AFX_FIELD_MAP line (.cpp file). >Now when I try to connect to the database using code that previously >worked I get an Assertion failure: >Debug Assertion Failed! >Program ...... >File: dbcore.cpp >Line:2578 The comments two lines before that ASSERT() say: // m_nFields doesn't relect number of // RFX_ output column calls in DoFieldExchange(). That means that you said you're going to have a certain number of columns, by setting m_nFields to that number. But you've bound some different number of columns, which is wrong. Since things don't lign up, MFC is warning you that something is amiss. >This assertion happens when I try to open the set. I do get the DBMS >login dialog and after I log in (supply the password) the assertion >happens. When I tried to debug this I saw that the assertion is a result >of issuing the MoveFirst() command after opening the set. >Apparently the set remains closed. Yes. Because opening it failed, that only makes sense. > Am I missing something ? Yes. > Where else should the code be changed to reflect the changes in the >database columns ? You should initialize m_nFields to one less than you were before, by the sounds of it. >Thanks in advance, Please buy me a Ducati 916. I promise not to ride in the rain. Thanks in advance! .B ekiM http://www.nwlink.com/~mikeblas/ These words are my own. I do not speak on behalf of Microsoft. -----From: John Fergusoni am on VC4.2EE, so the assertion on line:2578 doesn't help me. But i will take a guess. When you removed a field, did you also reduce the m_nFields parameter by 1? If you did not, this is most likely causing your assertion. m_nFields should match the number of columns that you are returning in your resultset and also the number of variables that you have setup to receive those columns. good luck,
Lior Messinger -- 100274.2607@compuserve.com Sunday, September 15, 1996 [Mini-digest: 2 responses] Ronen Ahlan, 1. In the constructor there's a variable set to the number of the fields (I think m_nFields or something like that). Did you decrement it? 2. I think the best lesson is: do as less things manualy as you can. IOW, use the class wizard again. Regards, Lior. ---------- Forwarded Message ---------- From: Ronen Ashkenazi, INTERNET:rashken@ms-israel.kla.com TO: "'mfcl'", INTERNET:MFC-L@NETCOM.COM DATE: 9/14/96 12:36 AM RE: Debug assertion using CRecordset. Enviroment: x86,NT 3.51,VC4.1 Hi, I have a CRecordset inherited object that's used to connect to my database through ODBC. When I created the CRecordset using class wizard I could connect to the database and everything worked just fine. I then had to delete a column from the database and made the necessary changes in my recordset. This included: 1. Removing the member variable representing that database column (.h file). 2. Removing the appropriate AFX_FIELD_MAP line (.cpp file). Now when I try to connect to the database using code that previously worked I get an Assertion failure: Debug Assertion Failed! Program ...... File: dbcore.cpp Line:2578 This assertion happens when I try to open the set. I do get the DBMS login dialog and after I log in (supply the password) the assertion happens. When I tried to debug this I saw that the assertion is a result of issuing the MoveFirst() command after opening the set. Apparently the set remains closed. Am I missing something ? Where else should the code be changed to reflect the changes in the database columns ? Thanks in advance, Ronen Ashkenazi. -----From: murugesh@mail.cswl.com Hai, Did u remove the RFX.... entry corresponding to the deleted column in DoFieldExchange? Did u set the m_nFields member to correct number of columns in the table? Hope, This helps. Regards Murugesh SS Murugesh@cswl.com
| Вернуться в корень Архива |