Navigation Error
-
As we know if a db contains atleast one record and the record pointer is on the First Record IsBOF() will return 0, and indeed after using m_pSet->MoveFirst() the value of IsBOF() is 0. But now in MS ACCESS the order of the records are as follows
Ac_No Name Author Type Value Date Stat 1111 Christmas Carol Charles Dickens 2 800 12/12/2006 2 1112 The Adventures of Hucklebery Finn Mark Twain 2 799 12/1/2005 1 1113 Chip DVD 06/06 Chip Magazine 1 100 1/6/2006 1 1114 Christmas Carol Charles Dickens 2 800 12/11/2006 1 1118 Last Christmas Eagles 1 299 1/4/2005 1 1119 The Adventures of Robinson Crusoe Daniel Dafoe 2 799 1/2/2002 1
Even after issuing MoveFirst() the pointer is pointing to 1118. weird:confused: Note: the fields might be a bit mangled plz bear.
Shouvik
-
As we know if a db contains atleast one record and the record pointer is on the First Record IsBOF() will return 0, and indeed after using m_pSet->MoveFirst() the value of IsBOF() is 0. But now in MS ACCESS the order of the records are as follows
Ac_No Name Author Type Value Date Stat 1111 Christmas Carol Charles Dickens 2 800 12/12/2006 2 1112 The Adventures of Hucklebery Finn Mark Twain 2 799 12/1/2005 1 1113 Chip DVD 06/06 Chip Magazine 1 100 1/6/2006 1 1114 Christmas Carol Charles Dickens 2 800 12/11/2006 1 1118 Last Christmas Eagles 1 299 1/4/2005 1 1119 The Adventures of Robinson Crusoe Daniel Dafoe 2 799 1/2/2002 1
Even after issuing MoveFirst() the pointer is pointing to 1118. weird:confused: Note: the fields might be a bit mangled plz bear.
Shouvik
shouvik.d wrote:
Even after issuing MoveFirst() the pointer is pointing to 1118
Have you queried for all these records ? If yes, have you used any
ORDER BY
clause ? Can you show that code ?Prasad Notifier using ATL | Operator new[],delete[][^]
-
shouvik.d wrote:
Even after issuing MoveFirst() the pointer is pointing to 1118
Have you queried for all these records ? If yes, have you used any
ORDER BY
clause ? Can you show that code ?Prasad Notifier using ATL | Operator new[],delete[][^]
can u let me know one thing. if in access i'm getting that specified view doesn't make sure that internally the record is stored in that order only. is it so. then this clarifies all my query. i mean i've entered all my recs in an ascending order format by Ac_No as primary key. So the disp is also in ascending order of the values of Ac_no. does that not mean the internal record storage order is the same:confused:
Shouvik
-
can u let me know one thing. if in access i'm getting that specified view doesn't make sure that internally the record is stored in that order only. is it so. then this clarifies all my query. i mean i've entered all my recs in an ascending order format by Ac_No as primary key. So the disp is also in ascending order of the values of Ac_no. does that not mean the internal record storage order is the same:confused:
Shouvik
shouvik.d wrote:
if in access i'm getting that specified view doesn't make sure that internally the record is stored in that order only
Not sure.
Prasad Notifier using ATL | Operator new[],delete[][^]
-
shouvik.d wrote:
Even after issuing MoveFirst() the pointer is pointing to 1118
Have you queried for all these records ? If yes, have you used any
ORDER BY
clause ? Can you show that code ?Prasad Notifier using ATL | Operator new[],delete[][^]
Here's my code. plz help u've always been to my rescue first time;)
`m_pSet->Close(); query="Select * from Book where Name like '%"+name.Left(5)+"%' AND Author LIKE '%"+auth.Left(5)+"%' Order By Ac_No" ; m_pSet->Open(CRecordset::dynaset, (LPCTSTR)query,CRecordset::none); m_pSet->MoveFirst(); do { Item.Empty(); name=m_pSet->m_Name; auth=m_pSet->m_Author; Item=m_pSet->m_Ac_No+"\t"+name+"\t"+auth+"\t"+CLibManView::GetStatus(m_pSet->m_Stat); lb->AddString(Item); m_pSet->MoveNext(); }while(!m_pSet->IsEOF());`
Hope this is suff 4 u
Shouvik
-
Here's my code. plz help u've always been to my rescue first time;)
`m_pSet->Close(); query="Select * from Book where Name like '%"+name.Left(5)+"%' AND Author LIKE '%"+auth.Left(5)+"%' Order By Ac_No" ; m_pSet->Open(CRecordset::dynaset, (LPCTSTR)query,CRecordset::none); m_pSet->MoveFirst(); do { Item.Empty(); name=m_pSet->m_Name; auth=m_pSet->m_Author; Item=m_pSet->m_Ac_No+"\t"+name+"\t"+auth+"\t"+CLibManView::GetStatus(m_pSet->m_Stat); lb->AddString(Item); m_pSet->MoveNext(); }while(!m_pSet->IsEOF());`
Hope this is suff 4 u
Shouvik
shouvik.d wrote:
query="Select * from Book where Name like '%"+name.Left(5)+"%' AND Author LIKE '%"+auth.Left(5)+"%' Order By Ac_No" ; m_pSet->Open(CRecordset::dynaset, (LPCTSTR)query,CRecordset::none);
I hope this gives you expected no. of records. Use
CRecordset::m_strSort
to sort the records.Prasad Notifier using ATL | Operator new[],delete[][^]
-
shouvik.d wrote:
query="Select * from Book where Name like '%"+name.Left(5)+"%' AND Author LIKE '%"+auth.Left(5)+"%' Order By Ac_No" ; m_pSet->Open(CRecordset::dynaset, (LPCTSTR)query,CRecordset::none);
I hope this gives you expected no. of records. Use
CRecordset::m_strSort
to sort the records.Prasad Notifier using ATL | Operator new[],delete[][^]
I tried but funniest part is its adding the records instead of sorting them so i used a query instead.
Shouvik
-
I tried but funniest part is its adding the records instead of sorting them so i used a query instead.
Shouvik
shouvik.d wrote:
I tried but funniest part is its adding the records instead of sorting them
Can you show code ? what you have tried ? It can be,
m_pSet->Open();
m_pSet->m_strSort = "par, par1";
m_pSet->Requery();//use CanRestart, to check if this function can be calledPrasad Notifier using ATL | Operator new[],delete[][^]
-
shouvik.d wrote:
I tried but funniest part is its adding the records instead of sorting them
Can you show code ? what you have tried ? It can be,
m_pSet->Open();
m_pSet->m_strSort = "par, par1";
m_pSet->Requery();//use CanRestart, to check if this function can be calledPrasad Notifier using ATL | Operator new[],delete[][^]
But the records are already sorted.
Shouvik
-
But the records are already sorted.
Shouvik
shouvik.d wrote:
But the records are already sorted
By what ? If it is sorted by
Ac_No
,MoveFirst()
should point to correct record in order.Prasad Notifier using ATL | Operator new[],delete[][^]
-
shouvik.d wrote:
I tried but funniest part is its adding the records instead of sorting them
Can you show code ? what you have tried ? It can be,
m_pSet->Open();
m_pSet->m_strSort = "par, par1";
m_pSet->Requery();//use CanRestart, to check if this function can be calledPrasad Notifier using ATL | Operator new[],delete[][^]
I said its all entered in Ascending order. So the retrievel is sorted irrespective of anything. Still the pointer remains stuck at 1118. i'm g:(ing nuts
Shouvik
-
Here's my code. plz help u've always been to my rescue first time;)
`m_pSet->Close(); query="Select * from Book where Name like '%"+name.Left(5)+"%' AND Author LIKE '%"+auth.Left(5)+"%' Order By Ac_No" ; m_pSet->Open(CRecordset::dynaset, (LPCTSTR)query,CRecordset::none); m_pSet->MoveFirst(); do { Item.Empty(); name=m_pSet->m_Name; auth=m_pSet->m_Author; Item=m_pSet->m_Ac_No+"\t"+name+"\t"+auth+"\t"+CLibManView::GetStatus(m_pSet->m_Stat); lb->AddString(Item); m_pSet->MoveNext(); }while(!m_pSet->IsEOF());`
Hope this is suff 4 u
Shouvik
Try this instead:
m_pSet->Close();
query = "Select * from Book where Name like '%" + name.Left(5) + "%' AND Author LIKE '%" + auth.Left(5) + "%' Order By Ac_No";
m_pSet->Open(CRecordset::dynaset, query, CRecordset::none);
while(! m_pSet->IsEOF())
{
name = m_pSet->m_Name;
auth = m_pSet->m_Author;
Item = m_pSet->m_Ac_No + "\t" + name + "\t" + auth + "\t" + CLibManView::GetStatus(m_pSet->m_Stat);
lb->AddString(Item);
m_pSet->MoveNext();
}
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
-
Try this instead:
m_pSet->Close();
query = "Select * from Book where Name like '%" + name.Left(5) + "%' AND Author LIKE '%" + auth.Left(5) + "%' Order By Ac_No";
m_pSet->Open(CRecordset::dynaset, query, CRecordset::none);
while(! m_pSet->IsEOF())
{
name = m_pSet->m_Name;
auth = m_pSet->m_Author;
Item = m_pSet->m_Ac_No + "\t" + name + "\t" + auth + "\t" + CLibManView::GetStatus(m_pSet->m_Stat);
lb->AddString(Item);
m_pSet->MoveNext();
}
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
Sorry David Still stuck at 1118. cant trace out the prob at all. I think the internal pattern of storage is so that 1118 is the first record.
Success makes life easier. It doesn't make living easier. SHOUVIK
-
Try this instead:
m_pSet->Close();
query = "Select * from Book where Name like '%" + name.Left(5) + "%' AND Author LIKE '%" + auth.Left(5) + "%' Order By Ac_No";
m_pSet->Open(CRecordset::dynaset, query, CRecordset::none);
while(! m_pSet->IsEOF())
{
name = m_pSet->m_Name;
auth = m_pSet->m_Author;
Item = m_pSet->m_Ac_No + "\t" + name + "\t" + auth + "\t" + CLibManView::GetStatus(m_pSet->m_Stat);
lb->AddString(Item);
m_pSet->MoveNext();
}
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
Since nothing worked out i changed the whole structure its like this
void CLibManView::OnDblclkBooks() { CString str; lb->GetText(lb->GetCurSel(),str); m_pSet->Close(); query = "Select * from Book where Ac_No='"+str.Left(4)+"'"; m_pSet->Open(CRecordset::dynaset, (LPCTSTR)query,CRecordset::none); if(m_pSet->IsBOF() && m_pSet->IsEOF()) MessageBox("No records available in the database"); else { MessageBox(m_pSet->m_Ac_No+" "+GetStatus(m_pSet->m_Stat)); } }
this works with precision :)
Success makes life easier. It doesn't make living easier. SH:)UVIK