vb.net database programming

  • Thread starter Thread starter sandy
  • Start date Start date
S

sandy

hi friends...
i am new to VB.NET.i was trying to read some data from the database
using code,
and display that in 2 textboxes.i was able to get only the first row.
i used ExecuteReader() function of SqlCommand class and read()
function to read data..
i have put a button on the form to advance the records..
in that click method i have called the read() function...
but it's not moving to the next record...even after clicking the
button...
please help me anyone...
thanks and regards...
sandeep...
 
Could you post your code? That way we can see what is going on.

Thanks,

Seth Rowe
 
Thanks Seth Rowe...

i will paste the code...


Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load

cn = New SqlConnection("Data Source=VIDYAMAYI18\SQLEXPRESS;Initial
Catalog=model;Integrated Security=True")

sqlcmd = New SqlCommand()
sqlcmd.CommandText = "select * from infotab"
sqlcmd.Connection = cn
cn.Open()
sqlreader = sqlcmd.ExecuteReader()

End Sub

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles nextbutton.Click

sqlreader.Read()
txtname.Text = sqlreader(0)
txtaddress.Text = sqlreader(1)

End Sub

Protected Sub Page_Unload(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Unload

cn.Close()

End Sub


i tried to fetch the records as i press the button and display the data
in textboxes...

thanks and regards
sandeep...
 
Back
Top