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
databasehelpregexlearning
8 Posts 2 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

    when the criteria for the where condition in a database query that i pumped in through

    m_pSet->Open(...,QUERY,...);
    

    and if no records match the criteria i'm gettin an error as Atttempt to scroll past end or before beginning of data in a dialog popped up. What can be the reason. the code is a follows.

                            query="Select * from Book where Name like '%"+name.Left(5)+"%'";
    			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());
    

    plz help

    Success makes life easier. It doesn't make living easier. SH:)UVIK

    S N 2 Replies Last reply
    0
    • S Shouvik Das

      when the criteria for the where condition in a database query that i pumped in through

      m_pSet->Open(...,QUERY,...);
      

      and if no records match the criteria i'm gettin an error as Atttempt to scroll past end or before beginning of data in a dialog popped up. What can be the reason. the code is a follows.

                              query="Select * from Book where Name like '%"+name.Left(5)+"%'";
      			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());
      

      plz help

      Success makes life easier. It doesn't make living easier. SH:)UVIK

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

      All seem to be on VACATION....;) Well well...Enjoy...Then do reply...

      Success makes life easier. It doesn't make living easier. SH:)UVIK

      1 Reply Last reply
      0
      • S Shouvik Das

        when the criteria for the where condition in a database query that i pumped in through

        m_pSet->Open(...,QUERY,...);
        

        and if no records match the criteria i'm gettin an error as Atttempt to scroll past end or before beginning of data in a dialog popped up. What can be the reason. the code is a follows.

                                query="Select * from Book where Name like '%"+name.Left(5)+"%'";
        			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());
        

        plz help

        Success makes life easier. It doesn't make living easier. SH:)UVIK

        N Offline
        N Offline
        Nibu babu thomas
        wrote on last edited by
        #3

        shouvik.d wrote:

        and if no records match the criteria i'm gettin an error as Atttempt to scroll past end or before beginning of data

        That's because you are calling MoveFirst when there are no records.


        Nibu thomas A Developer Programming tips[^]  My site[^]

        S 1 Reply Last reply
        0
        • N Nibu babu thomas

          shouvik.d wrote:

          and if no records match the criteria i'm gettin an error as Atttempt to scroll past end or before beginning of data

          That's because you are calling MoveFirst when there are no records.


          Nibu thomas A Developer Programming tips[^]  My site[^]

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

          there are 8 records present in the DB already

          Success makes life easier. It doesn't make living easier. SH:)UVIK

          N 1 Reply Last reply
          0
          • S Shouvik Das

            there are 8 records present in the DB already

            Success makes life easier. It doesn't make living easier. SH:)UVIK

            N Offline
            N Offline
            Nibu babu thomas
            wrote on last edited by
            #5

            shouvik.d wrote:

            there are 8 records present in the DB already

            I am not talking about DB, but about the result returned by the query. Get the count of records before moving around in a recordset.


            Nibu thomas A Developer Programming tips[^]  My site[^]

            S 1 Reply Last reply
            0
            • N Nibu babu thomas

              shouvik.d wrote:

              there are 8 records present in the DB already

              I am not talking about DB, but about the result returned by the query. Get the count of records before moving around in a recordset.


              Nibu thomas A Developer Programming tips[^]  My site[^]

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

              thanks prob solved :) I instead did this

                                m_pSet->Close();
              		query = "Select * from Book where Ac_no = '"+accnum+"'";
              		m_pSet->Open(CRecordset::dynaset, (LPCTSTR)query,CRecordset::none);
              	
              		if(m_pSet->IsBOF() && m_pSet->IsEOF())
              			MessageBox("No records meeting the criteria");
              		else
              		{
                                      m_pSet->MoveFirst();
              			do
              			{
              				name=m_pSet->m_Name;
              				auth=m_pSet->m_Author;
              				Item=accnum+"\t"+name+"\t"+auth+"\t"+CLibManView::GetStatus(m_pSet->m_Stat);
              				lb->AddString(Item);
              				m_pSet->MoveNext();
              			}while(!m_pSet->IsEOF());
              		}
              

              Success makes life easier. It doesn't make living easier. SH:)UVIK

              N 1 Reply Last reply
              0
              • S Shouvik Das

                thanks prob solved :) I instead did this

                                  m_pSet->Close();
                		query = "Select * from Book where Ac_no = '"+accnum+"'";
                		m_pSet->Open(CRecordset::dynaset, (LPCTSTR)query,CRecordset::none);
                	
                		if(m_pSet->IsBOF() && m_pSet->IsEOF())
                			MessageBox("No records meeting the criteria");
                		else
                		{
                                        m_pSet->MoveFirst();
                			do
                			{
                				name=m_pSet->m_Name;
                				auth=m_pSet->m_Author;
                				Item=accnum+"\t"+name+"\t"+auth+"\t"+CLibManView::GetStatus(m_pSet->m_Stat);
                				lb->AddString(Item);
                				m_pSet->MoveNext();
                			}while(!m_pSet->IsEOF());
                		}
                

                Success makes life easier. It doesn't make living easier. SH:)UVIK

                N Offline
                N Offline
                Nibu babu thomas
                wrote on last edited by
                #7

                Yeah. Always check status of db query results before using them.


                Nibu thomas A Developer Programming tips[^]  My site[^]

                S 1 Reply Last reply
                0
                • N Nibu babu thomas

                  Yeah. Always check status of db query results before using them.


                  Nibu thomas A Developer Programming tips[^]  My site[^]

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

                  plz can u reply to the prev page post titled Data Exchange Plz


                  Man can acquire accomplishments or he can become an animal, whichever he wants. God makes the animals, man makes himself. G. C. Lichtenberg (1742-99), German physicist, philosopher. 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