Loading 100 rows, reload after you hit the last row

Posted on 2006-05-09
Last Modified: 2010-04-23
It sounds easy to do, but I have written several things that did not work. I tried to create a function for this and it partially worked. Starting over now, this is all I have.

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        OleDbDataAdapter1.Fill(DataSet11, 1, 100, "table")
      End Sub
 Private Sub NavPrev_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Me.BindingContext(DataSet11, "table").Position = (Me.BindingContext(DataSet11, "table").Position - 1)
End Sub

 Private Sub navNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles navNext.Click
        Me.BindingContext(DataSet11, "table").Position = (Me.BindingContext(DataSet11, "table").Position + 1)
End Sub

Public Sub PositionChanged()
        Me.navlocation.Text = (((Me.BindingContext(DataSet11, "table").Position + 1).ToString + " of  ") _
               + Me.BindingContext(DataSet11, "table").Count.ToString)
End Sub
Question by:reefcrazed
    LVL 34

    Accepted Solution

    So what code did you try and what was the problem with it?  It looks as though this should work

           If Me.BindingContext(DataSet11, "table").Position = (Me.BindingContext(DataSet11, "table").Count -1) Then 'you're at the end ...

               'so get the next 100 starting from that number
               OleDbDataAdapter1.Fill(DataSet11, Me.BindingContext(DataSet11, "table").Count -1, 100, "table")

           End If

    at the start of your Sub navNext_Click should work.  But I haven't tested and I don't know if you've tried it and it doesn't.

    Just one point about your present code.  The StartRecord argument in the .Fill method you used is zero-based.  So with

            OleDbDataAdapter1.Fill(DataSet11, 1, 100, "table")

    you'll never retrieve the first record.  Is that intentional?


    Author Comment

    I think that is good enough for what I need.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
    Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now