Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB.NET
I want to loop through the records of the datatable and retrieve data from the each column of the datatableand fill the textboxes.
what should i do to moveNext button?
I have tried :
Protected Sub btn_next_Click(sender As Object, e As EventArgs) Handles btn_next.Click
 

        Dim i As Integer = 0
 

        For i = 0 To MaxRows
            i = i + 1
            NavigateRecords(i)
 
        Next
End Sub
 
Where  :
 MaxRows = tb.Rows.Count
 
 Private Sub NavigateRecords(int As Integer)
 

 

        Dim conn As New OleDb.OleDbConnection
        Dim strConn As String = "Provider=SQLOLEDB; Data Source=; Initial Catalog=; User ID=; Password="
 
        conn.ConnectionString = strConn
 
        conn.Open()
        Dim dst As New DataSet
        Dim da As OleDb.OleDbDataAdapter
        Dim tb As DataTable = dst.Tables("Client")
 
        Sqll = "SELECT * FROM Person"
 

 
        da = New OleDb.OleDbDataAdapter(Sqll, conn)
        da.Fill(dst, "Customer")
 MaxRows = tb.Rows.Count
       txt_vl.Value = tb.Rows(int).Item("value")
 
[Edit]Added code based on OP's comment[/Edit]
Posted 23-Nov-12 1:56am
Edited 23-Nov-12 2:59am
__TR__28.9K
v2
Comments
Annnaa at 23-Nov-12 7:12am
   
I have tried :
 
Protected Sub btn_next_Click(sender As Object, e As EventArgs) Handles btn_next.Click
 

Dim i As Integer = 0
 

For i = 0 To MaxRows
i = i + 1
NavigateRecords(i)
 
Next
End Sub
 
Where :
MaxRows = tb.Rows.Count
 
Private Sub NavigateRecords(int As Integer)
 

 

Dim conn As New OleDb.OleDbConnection
Dim strConn As String = "Provider=SQLOLEDB; Data Source=; Initial Catalog=; User ID=; Password="
 
conn.ConnectionString = strConn
 
conn.Open()
Dim dst As New DataSet
Dim da As OleDb.OleDbDataAdapter
Dim tb As DataTable = dst.Tables("Client")
 
Sqll = "SELECT * FROM Person"
 

 
da = New OleDb.OleDbDataAdapter(Sqll, conn)
da.Fill(dst, "Customer")
MaxRows = tb.Rows.Count
txt_vl.Value = tb.Rows(int).Item("value")
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

loop through all records:
Dim table As DataTable = GetTable
' Get the data table.
For Each row As DataRow In table.Rows
    Console.WriteLine("--- Row ---")
    ' Print separator.
    For Each item As var In row.ItemArray
        Console.Write("Item: ")
        ' Print label.
        Console.WriteLine(item)
        ' Invokes ToString abstract method.
    Next
Next
Console.Read
  Permalink  
Comments
Annnaa at 23-Nov-12 8:16am
   
what about if i want to create e previews button?
Krunal R at 23-Nov-12 8:21am
   
Like ???
Annnaa at 23-Nov-12 8:28am
   
for example:
Protected Sub btn_previews_Click(sender As Object, e As EventArgs) Handles btn_previews.Click
 
If (i > 0) Then
 
i = i - 1
 

NavigateRecords(i)
End If
End Sub
Krunal R at 23-Nov-12 8:33am
   
Okay, do this: I'm assuming that now you're able to go through each row ok.. So get the each row make the row as selected using currentRow-1... (Actually I'm not much good in VB .NET like C# .NET.. So I can help you with C# code)
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 7,903
1 Sergey Alexandrovich Kryukov 7,142
2 DamithSL 5,604
3 Manas Bhardwaj 4,986
4 Maciej Los 4,820


Advertise | Privacy | Mobile
Web02 | 2.8.1411023.1 | Last Updated 23 Nov 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100