循环数据表 [英] Looping for Datatable

查看:88
本文介绍了循环数据表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好咧嘴笑:-D



我正在使用VB 2008和VB.NET



我有一个数据库数据。每列即名称,年龄和爱好。 1人有多个爱好。每次用户键入名称时,都会直接显示其年龄和爱好。所以,我需要循环遍历dataset.table.row中的每个项目并想知道如何执行此操作。





  Dim  ds  As  DataSet 
Dim As DataRow

如果 ds.Tables。计数> 0 然后
如果 ds .Tables( 0 )。Rows.Count> 0 然后
对于 < span class =code-keyword>每个行 ds.Tables( 0 ) 。$ $

下一页

???









有人可以帮助我教我做这个循环或给出一些写这个循环的建议吗?提前谢谢微笑:)

解决方案

你几乎得到了它。尝试

  Dim  As  DataRow 

如果 ds.Tables.Count> 0 然后
如果 ds .Tables( 0 )。Rows.Count> 0 然后
对于 < span class =code-keyword>每个行 ds.Tables( 0 ) 。行
var age = row( 年龄
var hobby = row( Hobby
Next < /跨度>


Hi all Big Grin :-D

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 Smile :)

解决方案

You almost got it. Try

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
         var age = row("Age")
         var hobby = row("Hobby")
      Next


这篇关于循环数据表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆