can anyone help in gettin the records one after another from database on a form using vb.net(sql server)..but the below code displays only first record in the textboxes...
---------------------------------------
[code=vbnet]
private sub next_btn.click( byval,e)
Dim str As String = "select * from table1"
'try to write "select distinct * from table1"
Dim con As String = ConfigurationSe ttings.AppSetti ngs("preeconn")
Dim cmd As New SqlCommand(str, New SqlConnection(c on))
cmd.Connection. Open()
Dim da As New SqlDataAdapter( str, con)
Dim ds As New DataSet
da.Fill(ds, "table1")
Dim maxrws As Integer
Dim i As Integer
maxrws = ds.Tables("tabl e1").Rows.Cou nt 'used to get the count of number of rows in a table
i = 0
For i = 0 To maxrws - 1
id_txt.Text = ds.Tables("tabl e1").Rows(i).It em("ID").ToStri ng()
name_txt.Text = ds.Tables("tabl e1").Rows(i).It em("Name").ToSt ring()
age_txt.Text = ds.Tables("tabl e1").Rows(i).It em("Age").ToStr ing()
sex_txt.Text = ds.Tables("tabl e1").Rows(i).It em("Sex").ToStr ing()
area_txt.Text = ds.Tables("tabl e1").Rows(i).It em("Area").ToSt ring()
Next i
'id_txt.Text = ds.Tables("tabl e1").Rows.Add
'id_txt.Text = ds.Tables("tabl e1").Rows(i).It em("ID").ToStri ng()
name_txt.Text = ds.Tables("tabl e1").Rows(i).It em("Name").ToSt ring()
age_txt.Text = ds.Tables("tabl e1").Rows(i).It em("Age").ToStr ing()
sex_txt.Text = ds.Tables("tabl e1").Rows(i).It em("Sex").ToStr ing()
area_txt.Text = ds.Tables("tabl e1").Rows(i).It em("Area").ToSt ring()[/code]
---------------------------------------
[code=vbnet]
private sub next_btn.click( byval,e)
Dim str As String = "select * from table1"
'try to write "select distinct * from table1"
Dim con As String = ConfigurationSe ttings.AppSetti ngs("preeconn")
Dim cmd As New SqlCommand(str, New SqlConnection(c on))
cmd.Connection. Open()
Dim da As New SqlDataAdapter( str, con)
Dim ds As New DataSet
da.Fill(ds, "table1")
Dim maxrws As Integer
Dim i As Integer
maxrws = ds.Tables("tabl e1").Rows.Cou nt 'used to get the count of number of rows in a table
i = 0
For i = 0 To maxrws - 1
id_txt.Text = ds.Tables("tabl e1").Rows(i).It em("ID").ToStri ng()
name_txt.Text = ds.Tables("tabl e1").Rows(i).It em("Name").ToSt ring()
age_txt.Text = ds.Tables("tabl e1").Rows(i).It em("Age").ToStr ing()
sex_txt.Text = ds.Tables("tabl e1").Rows(i).It em("Sex").ToStr ing()
area_txt.Text = ds.Tables("tabl e1").Rows(i).It em("Area").ToSt ring()
Next i
'id_txt.Text = ds.Tables("tabl e1").Rows.Add
'id_txt.Text = ds.Tables("tabl e1").Rows(i).It em("ID").ToStri ng()
name_txt.Text = ds.Tables("tabl e1").Rows(i).It em("Name").ToSt ring()
age_txt.Text = ds.Tables("tabl e1").Rows(i).It em("Age").ToStr ing()
sex_txt.Text = ds.Tables("tabl e1").Rows(i).It em("Sex").ToStr ing()
area_txt.Text = ds.Tables("tabl e1").Rows(i).It em("Area").ToSt ring()[/code]
Comment