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. CDaoRecordset Problem..

CDaoRecordset Problem..

Scheduled Pinned Locked Moved C / C++ / MFC
helpdatabase
3 Posts 3 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.
  • J Offline
    J Offline
    jadhavjitendrar
    wrote on last edited by
    #1

    Hi friends, Below line contain my code.I m writting data into the text file.i have acess database and i write this databse into text file format. my access databse table contain 99 records and i m using CDaoRecordset MoveNext() to get next record data.Problem is that i get record till 18 its ok but after that i get 20 position record and afterthat i get 19 position record.then i get 26 to 30 position record and then i get 21 to 25 record data.But data in the database table is sequentially.So why this problem will occour i wont understand. Plz help me.. m_pRecordSet = new CDaoRecordset(m_pDatabase); CString strTablename = _T("pdpstate"); m_pRecordSet->Open(dbOpenTable,strTablename); int nRecordCnt = m_pRecordSet->GetRecordCount(); int nFieldCnt = m_pRecordSet->GetFieldCount(); CDaoFieldInfo cTempdaoFieldInfo; CString csSetID,csFieldStr; CStdioFile cTestFile; cTestFile.Open(_T("d:\\Jitu45.txt"),CStdioFile::modeCreate | CStdioFile::modeWrite); for(int nfCnt = 0; nfCnt < nFieldCnt; nfCnt++) { m_pRecordSet->GetFieldInfo(nfCnt,cTempdaoFieldInfo); cTestFile.WriteString(cTempdaoFieldInfo.m_strName); cTestFile.WriteString(_T(",")); } cTestFile.WriteString(_T("\n")); while(!m_pRecordSet->IsEOF()) { COleVariant variantTemp; //..// Move through fields in current record.. int nFields = m_pRecordSet->GetFieldCount(); for ( int i=0; i < nFields; i++ ) { variantTemp.Clear(); variantTemp = m_pRecordSet->GetFieldValue(i); csSetID.Format(_T("%d"),variantTemp.intVal); cTestFile.WriteString(csSetID); cTestFile.WriteString(_T(",")); } cTestFile.WriteString(_T("\n")); m_pRecordSet->MoveNext(); } cTestFile.Close();

    C R 2 Replies Last reply
    0
    • J jadhavjitendrar

      Hi friends, Below line contain my code.I m writting data into the text file.i have acess database and i write this databse into text file format. my access databse table contain 99 records and i m using CDaoRecordset MoveNext() to get next record data.Problem is that i get record till 18 its ok but after that i get 20 position record and afterthat i get 19 position record.then i get 26 to 30 position record and then i get 21 to 25 record data.But data in the database table is sequentially.So why this problem will occour i wont understand. Plz help me.. m_pRecordSet = new CDaoRecordset(m_pDatabase); CString strTablename = _T("pdpstate"); m_pRecordSet->Open(dbOpenTable,strTablename); int nRecordCnt = m_pRecordSet->GetRecordCount(); int nFieldCnt = m_pRecordSet->GetFieldCount(); CDaoFieldInfo cTempdaoFieldInfo; CString csSetID,csFieldStr; CStdioFile cTestFile; cTestFile.Open(_T("d:\\Jitu45.txt"),CStdioFile::modeCreate | CStdioFile::modeWrite); for(int nfCnt = 0; nfCnt < nFieldCnt; nfCnt++) { m_pRecordSet->GetFieldInfo(nfCnt,cTempdaoFieldInfo); cTestFile.WriteString(cTempdaoFieldInfo.m_strName); cTestFile.WriteString(_T(",")); } cTestFile.WriteString(_T("\n")); while(!m_pRecordSet->IsEOF()) { COleVariant variantTemp; //..// Move through fields in current record.. int nFields = m_pRecordSet->GetFieldCount(); for ( int i=0; i < nFields; i++ ) { variantTemp.Clear(); variantTemp = m_pRecordSet->GetFieldValue(i); csSetID.Format(_T("%d"),variantTemp.intVal); cTestFile.WriteString(csSetID); cTestFile.WriteString(_T(",")); } cTestFile.WriteString(_T("\n")); m_pRecordSet->MoveNext(); } cTestFile.Close();

      C Offline
      C Offline
      CPallini
      wrote on last edited by
      #2

      What about an ORDER BY clause in the query? :)

      If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
      This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
      [My articles]

      1 Reply Last reply
      0
      • J jadhavjitendrar

        Hi friends, Below line contain my code.I m writting data into the text file.i have acess database and i write this databse into text file format. my access databse table contain 99 records and i m using CDaoRecordset MoveNext() to get next record data.Problem is that i get record till 18 its ok but after that i get 20 position record and afterthat i get 19 position record.then i get 26 to 30 position record and then i get 21 to 25 record data.But data in the database table is sequentially.So why this problem will occour i wont understand. Plz help me.. m_pRecordSet = new CDaoRecordset(m_pDatabase); CString strTablename = _T("pdpstate"); m_pRecordSet->Open(dbOpenTable,strTablename); int nRecordCnt = m_pRecordSet->GetRecordCount(); int nFieldCnt = m_pRecordSet->GetFieldCount(); CDaoFieldInfo cTempdaoFieldInfo; CString csSetID,csFieldStr; CStdioFile cTestFile; cTestFile.Open(_T("d:\\Jitu45.txt"),CStdioFile::modeCreate | CStdioFile::modeWrite); for(int nfCnt = 0; nfCnt < nFieldCnt; nfCnt++) { m_pRecordSet->GetFieldInfo(nfCnt,cTempdaoFieldInfo); cTestFile.WriteString(cTempdaoFieldInfo.m_strName); cTestFile.WriteString(_T(",")); } cTestFile.WriteString(_T("\n")); while(!m_pRecordSet->IsEOF()) { COleVariant variantTemp; //..// Move through fields in current record.. int nFields = m_pRecordSet->GetFieldCount(); for ( int i=0; i < nFields; i++ ) { variantTemp.Clear(); variantTemp = m_pRecordSet->GetFieldValue(i); csSetID.Format(_T("%d"),variantTemp.intVal); cTestFile.WriteString(csSetID); cTestFile.WriteString(_T(",")); } cTestFile.WriteString(_T("\n")); m_pRecordSet->MoveNext(); } cTestFile.Close();

        R Offline
        R Offline
        ramana g
        wrote on last edited by
        #3

        ORDER BY can be achieved by setting the COLUMN_NAME by which you want to sort the records to the "m_strSort" member of the CDaoRecordset class.

        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