Displaying next record of a datareader.

srithil

Newcomer
Joined
Apr 30, 2004
Messages
21
Hai, i am clicking a button 'findnext' and calling the event btnclick on its onclick event.I want to display the records in my form fields one by one.
The following code displays only the first record of the datareader in my fields.
I want to display my next record when i click the button findnext.
How do i display my second record of the datareader??
anybody pls help.

tx


sub btnclick(sender as object,e as eventargs)

Dim mydr1 As SqlDataReader


sql1 = "SELECT * FROM Nt_site_contact WHERE " & _
"first_name = '" & s & "'"
'connections goes here
mydr1 = mycmd1.ExecuteReader()
mydr1.read()

While mydr1.Read()
pp_last.text =mydr1("last_name")
pp_address1.text=mydr1("Address1")
End While
mydr1.Close()

mycon1.Close()

end sub.
 
you can use the Read method to jump to the next record in a dataReader. But you can't maintain the datareader between requests, so I suggest using a dataset and storing in a session variable
 
hai tx,

i am new to asp.net.If possible can u please post me the codes to store in a session variable using dataset.
 
to store in a session variable

Session.items.Add("myDataSet",dataset)

to retrieve from session variavle

Dim ds As DataSet = Ctype(Session.item("myDataSet"),DataSet)
 
Back
Top