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

Navigation Error

Scheduled Pinned Locked Moved C / C++ / MFC
databasehelp
14 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.
  • S Offline
    S Offline
    Shouvik Das
    wrote on last edited by
    #1

    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

    P 1 Reply Last reply
    0
    • S Shouvik Das

      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

      P Offline
      P Offline
      prasad_som
      wrote on last edited by
      #2

      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[][^]

      S 2 Replies Last reply
      0
      • P prasad_som

        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[][^]

        S Offline
        S Offline
        Shouvik Das
        wrote on last edited by
        #3

        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

        P 1 Reply Last reply
        0
        • S Shouvik Das

          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

          P Offline
          P Offline
          prasad_som
          wrote on last edited by
          #4

          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[][^]

          1 Reply Last reply
          0
          • P prasad_som

            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[][^]

            S Offline
            S Offline
            Shouvik Das
            wrote on last edited by
            #5

            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

            P D 2 Replies Last reply
            0
            • S Shouvik Das

              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

              P Offline
              P Offline
              prasad_som
              wrote on last edited by
              #6

              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[][^]

              S 1 Reply Last reply
              0
              • P prasad_som

                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[][^]

                S Offline
                S Offline
                Shouvik Das
                wrote on last edited by
                #7

                I tried but funniest part is its adding the records instead of sorting them so i used a query instead.

                Shouvik

                P 1 Reply Last reply
                0
                • S Shouvik Das

                  I tried but funniest part is its adding the records instead of sorting them so i used a query instead.

                  Shouvik

                  P Offline
                  P Offline
                  prasad_som
                  wrote on last edited by
                  #8

                  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 called

                  Prasad Notifier using ATL | Operator new[],delete[][^]

                  S 2 Replies Last reply
                  0
                  • P prasad_som

                    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 called

                    Prasad Notifier using ATL | Operator new[],delete[][^]

                    S Offline
                    S Offline
                    Shouvik Das
                    wrote on last edited by
                    #9

                    But the records are already sorted.

                    Shouvik

                    P 1 Reply Last reply
                    0
                    • S Shouvik Das

                      But the records are already sorted.

                      Shouvik

                      P Offline
                      P Offline
                      prasad_som
                      wrote on last edited by
                      #10

                      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[][^]

                      1 Reply Last reply
                      0
                      • P prasad_som

                        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 called

                        Prasad Notifier using ATL | Operator new[],delete[][^]

                        S Offline
                        S Offline
                        Shouvik Das
                        wrote on last edited by
                        #11

                        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

                        1 Reply Last reply
                        0
                        • S Shouvik Das

                          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

                          D Offline
                          D Offline
                          David Crow
                          wrote on last edited by
                          #12

                          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

                          S 2 Replies Last reply
                          0
                          • D David Crow

                            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

                            S Offline
                            S Offline
                            Shouvik Das
                            wrote on last edited by
                            #13

                            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

                            1 Reply Last reply
                            0
                            • D David Crow

                              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

                              S Offline
                              S Offline
                              Shouvik Das
                              wrote on last edited by
                              #14

                              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

                              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