By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,640 Members | 2,077 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,640 IT Pros & Developers. It's quick & easy.

Looping for Datatable

P: 1
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 :

Expand|Select|Wrap|Line Numbers
  1. Dim ds As DataSet
  2. Dim row As DataRow
  4. If ds.Tables.Count > 0 Then
  5.    If ds.Tables(0).Rows.Count > 0 Then
  6.       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

Can someone help me to teach me to make this loop.
Thank you in advance :)
Attached Images
File Type: jpg Capture3.jpg (32.9 KB, 35 views)
File Type: png Capture2.PNG (5.6 KB, 45 views)
Apr 6 '15 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.