To find next and previous record

cheruvannoor

Member
Joined
Aug 23, 2005
Messages
13
Programming Experience
Beginner
i just a beginner of vb.net..i want to get code for find 'next and previous' record from sql database through vb.net form that i made with buttons
my code is given below..


Dim query As String
conn = New SqlConnection
conn.ConnectionString = "data source=localhost;initial catalog=CARGO;user id=sa;pwd="
conn.Open()
'MsgBox("connected")
myconn = New SqlCommand
myconn.Connection = conn
query = "select * from branch"
myconn.CommandText = query
myreader = myconn.ExecuteReader()
Do While myreader.Read
Txtkey.Text = myreader.GetValue(0)
Txtbranch.Text = myreader.GetValue(2)
Txtdetails.Text = myreader.GetValue(3)
ComboBox1.Text = myreader.GetValue(1)
DtP.Value = myreader.GetDateTime(4)

Loop
Butnedit.Enabled = True
Butndelete.Enabled = True
Butnok.Enabled = False
Butncancel.Enabled = False
Butnnext.Enabled = False
Butnprevious.Enabled = True
 
Back
Top