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.table.row and wondering how to do this.

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
Next ???

Can someone help me to teach me to make this loop or give some suggestion to write this loop?
Thank you in advance :)

How do you want to display this?

Also you say 1 person has potentially more than 1 hobby. How are you dealing with this in your database design?

Showing us the Sql statement you use would be helpful.

My user interface will look alike like this :

My database :


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 hooby 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

Ok first things first, before getting your code to work lets fix your database as the design is wrong.

There are a set of design guidelines for designing databases called normalisation.

The rules or guidelines help you create databases which are not problematic.

In yours for example you repeat persons name and age for each hobby.

There are a couple of solutions to fixing this design. Its easy enough to explain - I could do it in 10 minutes if you were sat in front of me with a whiteboard but it would take a lot of typing to do it here!

You should google database normalisation and find a tutorial that suits your learning style, or find one on you tube.

After that shout up if you have any questions and after we get your database fixed we can fix your code.