Looping for Datatable

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • applebiru
    New Member
    • Apr 2015
    • 1

    Looping for Datatable

    Hi all :)


    I'm using VB 2008 and VB.NET

    I have a database data. Each column namely as name, age and hobby. For 1 person have more than one hobby. Each time user key in the name, it will directly display their age and hobby. So, I need to loop through each item in the dataset for column hobby and display it by each line/row by calling a different label control. I'm wondering how to do this. Code :

    Code:
    Dim ds As DataSet
    Dim row As DataRow
    
    If ds.Tables.Count > 0 Then
       If ds.Tables(0).Rows.Count > 0 Then
          For Each row In ds.Tables(0).Rows
    Screenshot for database and user interface show in attachment below.


    My user interface : Capture3

    My database : Capture2

    Each time user key in the name of name textbox, it also will directly display age and their hobby. I had problem on how to make the loop for hobby column and to display it according to the label. In other word, I would like to make my program display as below :

    Name : Jason

    Age : 20

    Hobby : Swimming
    Games

    Can someone help me to teach me to make this loop.
    Thank you in advance :)
    Attached Files
    Last edited by applebiru; Apr 6 '15, 07:24 AM. Reason: Error
Working...