[英]Looping through dataset and storing data in array in visual basic
I am trying to load all the groups into an Array
then loop through those groups and see how many assets they have per agent, if assets are more than agents than move them to our dummy group 0. but i am new to this DataSet
and TableAdapator
. 我正在尝试将所有组加载到Array
然后遍历这些组并查看每个代理有多少资产(如果资产多于代理,而不是将它们移动到我们的虚拟组0中。)但是我对此DataSet
和TableAdapator
。
basically Group--agent--assets 基本上是组-代理-资产
0--0--10
1--3--3
2--3--5
3--10--15
so group 2 has 2 extra assets i want to move them to our empty group 0 所以第2组有2个额外的资产,我想将它们移到我们的空组0
Please guide 请指导
Dim rs, lines
rs = cn.Execute("select grp from tskmsgrp where listid = 0;")
Dim da As New System.Data.OleDb.OleDbDataAdapter()
Dim da_line As New System.Data.OleDb.OleDbDataAdapter()
Dim ds As New DataSet()
da.Fill(ds, rs, "grp")
MsgBox("There are total products." & ds.Tables(0).Rows.Count.ToString)
For Each a As DataRow In ds.Tables(0).Rows
lines = cn.Execute("select count(*) from tsklines where grp ='" & a(0) & "';")
Dim ds_lines As New DataSet()
da_line.Fill(ds_lines, lines, "lines")
MsgBox("Lines for group." & a(0) & " -- " & ds_lines.Tables(0).Rows.Count.ToString)
Next
A couple of points -- you can work out the details. 有两点-您可以确定细节。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.