CDaoRecordset Problem..
-
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();
-
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();
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] -
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();