By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,325 Members | 1,128 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,325 IT Pros & Developers. It's quick & easy.

Select next record from mysql db

100+
P: 137
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:
Expand|Select|Wrap|Line Numbers
  1. conn = New MySqlConnection
  2.             Dim Command As New MySqlCommand
  3.             Dim Data As MySqlDataReader
  4.             Dim myAdapter As New MySql.Data.MySqlClient.MySqlDataAdapter
  5.             Dim Sql As String
  6.             Dim Rows As Integer = 0
  7.  
  8. conn.ConnectionString = "server=" & My.Settings.Server & ";" & "user id=" & My.Settings.Loginnaam & ";" _
  9.                                        & "password=" & My.Settings.Passwoord & ";" & "database=" & My.Settings.Database
  10.  
  11.                 Sql = "SELECT * FROM device, customer WHERE (Device.customerID = customer.ID) AND " & Search & " LIKE '%" & SearchText & "%'  ORDER BY device.ID;"
  12.  
  13.                 conn.Open()
  14.                 Command.Connection = conn
  15.                 Command.CommandText = Sql
  16.  
  17.                 Data = Command.ExecuteReader
  18.                 If Data.HasRows = False Then
  19.                     MessageBox.Show("No records found", "Albersoft - RepairService", MessageBoxButtons.OK, MessageBoxIcon.Information)
  20.                     Info_Load(sender, e)
  21.                 Else
  22.                     While Data.Read()
  23. 'doing thing..
  24. End While
  25.  

Somebody some advice?

I mean it's a kind of pagination thing.

Gr Paul
Feb 19 '08 #1
Share this Question
Share on Google+
2 Replies

Plater
Expert 5K+
P: 7,872
The lines
While Data.Read()
'doing thing..
Each call to .Read() moves to the next record.
I would recomend creating a DataTable (Look up MySqlDataAdapter'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.
Feb 19 '08 #2

100+
P: 137
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
Feb 20 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.