|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
vb.net database programminghi 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 sandy wrote: Show quoteHide quote > 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... 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... Sandy,
Just use Databinding that makes it more easy and more from this time. http://www.vb-tips.com/dbpages.aspx?ID=c4832a2a-2b95-4ded-93d9-4deb7fa4a0b8 I hope this helps, Cor Show quoteHide quote "sandy" <sandy4***@gmail.com> schreef in bericht news:1160831843.705145.254210@k70g2000cwa.googlegroups.com... > 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... > |
|||||||||||||||||||||||