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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Update (ADO) problem

Update (ADO) problem

Scheduled Pinned Locked Moved C / C++ / MFC
helpannouncement
5 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.
  • N Offline
    N Offline
    nss
    wrote on last edited by
    #1

    It crashes at the update().I checked to see that there was valid data in in the fields after being assigned.

    	while (!m_db1.m_pRecordset->GetadoEOF ())
    	{
    
    
    		m_db3.Open(DatabaseName3); 
    
    		int n = m_db3.m_pRecordset->RecordCount;
    		
    		m_db3.m_pRecordset->AddNew();
    
    		std::set::iterator itA = m_set3.begin();
    
    		for(; itA != m_set3.end(); itA++)
    		{
    			tempStr = *itA;
    
    
    
    			char* fldIt1 = new char [tempStr.GetLength() + 1];  
    			strcpy(fldIt1, tempStr);
    	////////////////////////////////////////////////////////////////////////////
    
    
    			CString strTemp((char*)(_bstr_t)(m_db1.m_pRecordset->Fields->Item[fldIt1]->Value));
    
    //			CString dummy = strTemp;
    
    			m_db3.m_pRecordset->Fields->Item[fldIt1]->Value = m_db1.m_pRecordset->Fields->Item[fldIt1]->Value;
    ;
    
    			delete[] fldIt1;
    
    		}
    	 m_db1.m_pRecordset->MoveNext();
    	 m_db3.m_pRecordset->Update();
    
    
    	 m_db3.m_pRecordset->Close();
    
    	 m_db3.m_pRecordset = NULL;
    
    	 m_db3.Close();
       }
    
    G 1 Reply Last reply
    0
    • N nss

      It crashes at the update().I checked to see that there was valid data in in the fields after being assigned.

      	while (!m_db1.m_pRecordset->GetadoEOF ())
      	{
      
      
      		m_db3.Open(DatabaseName3); 
      
      		int n = m_db3.m_pRecordset->RecordCount;
      		
      		m_db3.m_pRecordset->AddNew();
      
      		std::set::iterator itA = m_set3.begin();
      
      		for(; itA != m_set3.end(); itA++)
      		{
      			tempStr = *itA;
      
      
      
      			char* fldIt1 = new char [tempStr.GetLength() + 1];  
      			strcpy(fldIt1, tempStr);
      	////////////////////////////////////////////////////////////////////////////
      
      
      			CString strTemp((char*)(_bstr_t)(m_db1.m_pRecordset->Fields->Item[fldIt1]->Value));
      
      //			CString dummy = strTemp;
      
      			m_db3.m_pRecordset->Fields->Item[fldIt1]->Value = m_db1.m_pRecordset->Fields->Item[fldIt1]->Value;
      ;
      
      			delete[] fldIt1;
      
      		}
      	 m_db1.m_pRecordset->MoveNext();
      	 m_db3.m_pRecordset->Update();
      
      
      	 m_db3.m_pRecordset->Close();
      
      	 m_db3.m_pRecordset = NULL;
      
      	 m_db3.Close();
         }
      
      G Offline
      G Offline
      Giles
      wrote on last edited by
      #2

      You have MoveNext before the Update.

      N 1 Reply Last reply
      0
      • G Giles

        You have MoveNext before the Update.

        N Offline
        N Offline
        nss
        wrote on last edited by
        #3

        Thanks. But actually thats the movenext for a different database. I'm cycling through 1 and adding to another.....but thank you anyway :) ns I did find my problem a few minutes ago (hurrah!). I had added and populated a field in the new databse, but didnt realize I had to close and reopen it for the change to be visible to the program. Once I did that things are going along fine!

        G 1 Reply Last reply
        0
        • N nss

          Thanks. But actually thats the movenext for a different database. I'm cycling through 1 and adding to another.....but thank you anyway :) ns I did find my problem a few minutes ago (hurrah!). I had added and populated a field in the new databse, but didnt realize I had to close and reopen it for the change to be visible to the program. Once I did that things are going along fine!

          G Offline
          G Offline
          Giles
          wrote on last edited by
          #4

          nss wrote: Thanks. But actually thats the movenext for a different database. I'm cycling through 1 and adding to another.....but thank you anyway ns Ooops. :-O nss wrote: I did find my problem a few minutes ago (hurrah!). I had added and populated a field in the new databse, but didnt realize I had to close and reopen it for the change to be visible to the program. Once I did that things are going along fine! Which database are you using, and what version of ADO? I had a similar problem with an Access 97 database, with the field not updating unless I closed and reopened the recordset. It turned out to be a bug in the Jet driver for 97, so moving to Access 2000 DB fixed it, so that when I called update the correct value was there.

          N 1 Reply Last reply
          0
          • G Giles

            nss wrote: Thanks. But actually thats the movenext for a different database. I'm cycling through 1 and adding to another.....but thank you anyway ns Ooops. :-O nss wrote: I did find my problem a few minutes ago (hurrah!). I had added and populated a field in the new databse, but didnt realize I had to close and reopen it for the change to be visible to the program. Once I did that things are going along fine! Which database are you using, and what version of ADO? I had a similar problem with an Access 97 database, with the field not updating unless I closed and reopened the recordset. It turned out to be a bug in the Jet driver for 97, so moving to Access 2000 DB fixed it, so that when I called update the correct value was there.

            N Offline
            N Offline
            nss
            wrote on last edited by
            #5

            Access 2000. What it was unhappy about was that I was trying to access a value from the ew column, and even though if I looked in Access, the new column was added, apparently the code was clueless. Its msado25.tlb. Was using a later version, with msado15, but it wouldnt run on some machines - an MDAC mismatch. I should add that the problem was with the database I was reading from (to which I'd added a column), but once the open-close thing was resolved, tht database I was writing to, and updating had no problem. I didnt have to close and open it multipe times...

            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