Navigation Error
-
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