Select next record from mysql db

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • djpaul
    New Member
    • Oct 2006
    • 137

    Select next record from mysql db

    Hello,
    I am creating a program to save repair reports from audio/video equipment.
    But i created also a searchbox wich displays 1 or more records.
    But how can i get the next record when i press on a button 'next' or 'previous'?

    This is some of my code:
    [CODE=vbnet]conn = New MySqlConnection
    Dim Command As New MySqlCommand
    Dim Data As MySqlDataReader
    Dim myAdapter As New MySql.Data.MySq lClient.MySqlDa taAdapter
    Dim Sql As String
    Dim Rows As Integer = 0

    conn.Connection String = "server=" & My.Settings.Ser ver & ";" & "user id=" & My.Settings.Log innaam & ";" _
    & "password=" & My.Settings.Pas swoord & ";" & "database=" & My.Settings.Dat abase

    Sql = "SELECT * FROM device, customer WHERE (Device.custome rID = customer.ID) AND " & Search & " LIKE '%" & SearchText & "%' ORDER BY device.ID;"

    conn.Open()
    Command.Connect ion = conn
    Command.Command Text = Sql

    Data = Command.Execute Reader
    If Data.HasRows = False Then
    MessageBox.Show ("No records found", "Albersoft - RepairService", MessageBoxButto ns.OK, MessageBoxIcon. Information)
    Info_Load(sende r, e)
    Else
    While Data.Read()
    'doing thing..
    End While
    [/CODE]


    Somebody some advice?

    I mean it's a kind of pagination thing.

    Gr Paul
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    The lines
    While Data.Read()
    'doing thing..
    Each call to .Read() moves to the next record.
    I would recomend creating a DataTable (Look up MySqlDataAdapte r's for an easy way to do that) and using the datatable for things.
    At very least it will give you an indexable set of records so you can move forward and back.

    Comment

    • djpaul
      New Member
      • Oct 2006
      • 137

      #3
      Ohkay,
      So i don't have to use the function LIMIT 0, 2(of course with some variables) and so on.
      I will found it out!

      Thanks!
      Paul

      Comment

      Working...