Question next and previous buttons

developer_mahmoud

Well-known member
Joined
Nov 13, 2010
Messages
64
Programming Experience
1-3
hi
i use the following code to retrieve picture from a database in to picturebox but i need the next and previous buttons to navigate through records
CON.Open()

Dim sql As String = "Select * from student where rollno=@rollno"

Dim cmd As New OleDbCommand(sql, CON)
cmd.Parameters.AddWithValue("@rollno", TextBox5.Text)

Dim dr As OleDbDataReader = cmd.ExecuteReader()

If dr.HasRows Then

dr.Read()

TextBox6.Text = dr("name").ToString()

Dim data As Byte() = DirectCast(dr("photo"), Byte())

Dim ms As New IO.MemoryStream(data)

PictureBox1.Image = Image.FromStream(ms)

End If

CON.Close()
 
There is no one way to do it. You first need to decide what data you want to get when. You have four choices:

1. Get all the data at the beginning. You will work with just the local data.
2. Get all data except the images at the beginning. Each time you select a new record, you will then retrieve the image for that record.
3. Get just the IDs at the beginning. Each time the user selects an ID, you will then get the rest of the data for that record.
4. Get no data at the beginning. Each time the user wants to navigate, you have to pass the current record ID to the database in order fro it to determine first what the next ID is and then get the record with that ID.

There are two primary factors that will help you decide which of those options to take: how much data there is in total and how much of that data the user is likely to view in a session.
 
Back
Top