473,326 Members | 2,588 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Select next record from mysql db

137 100+
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
2 1394
Plater
7,872 Expert 4TB
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
djpaul
137 100+
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

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

Similar topics

9
by: atse | last post by:
Hi, My table in the database may contain duplicate records, which means except the primary key (auto_increment) field is unique, all or almost of all the fields are with the same content. How...
0
by: Richard Bolen | last post by:
I'm trying to write a select query that involves 2 tables. One table (Submissions) has a one to many relationship with the other table (Jobs). I'm trying to find all the records in Jobs that do...
4
by: Denis St-Michel | last post by:
Hello All, Hope some Guru will be able to help me with this. Let's take this example table A ------------------------------------------------------------------------------- id | ...
5
by: jayson_13 | last post by:
Hi, I need to implement a counter and i face problem of locking so hope that u guys can help me. I try to do test like this : 1st connection SELECT * FROM nextkey WHERE tblname = 'PLCN'...
11
by: pmarisole | last post by:
I am trying to use the vbscript "split" function on a multi-select field. I am trying to do a mass update of several records at a time. I am getting an error and I'm not sure what to do. Here is...
11
by: pmarisole | last post by:
I am using the following code to split/join values in a multi-select field. It is combining all the values in All the records into one long string in each record in recordset. Example: I have a...
1
by: bpforte | last post by:
Hello, I need help with building query, basically I need to select all records from one table that don't exists in second table with status 1, but they can exists in second table with status 0, to...
1
by: write2ashokkumar | last post by:
hi.... i am using mysql 5.0.22 version. i have the table xxx with 2 lakhs record. if i select all the records...it takes the long time to give the result set. is there any way to fine tune...
1
by: Sunray | last post by:
I have a form called the sales form and i have 2 sets of listboxes So what happens is. i add items form the bottom set of list boxes which are bound to a data base to the top set of list boxes which...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.