0

我正在尝试将所有组加载到Array然后循环遍历这些组,并查看每个代理有多少资产,如果资产不仅仅是代理而不是将它们移动到我们的虚拟组 0。但我对此并不陌生,DataSet并且TableAdapator.

基本上是集团--代理--资产

0--0--10
1--3--3
2--3--5
3--10--15

所以第 2 组有 2 个额外资产我想将它们移动到我们的空组 0

请指导

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
4

1 回答 1

0

几点——你可以弄清楚细节。

  1. 您不需要循环内的 select 语句,因为您可以访问 a 行中的数据。
  2. 您不需要再次填充数据集,只需更新 ds. 循环完成后,您可以一次全部更新。
于 2013-01-09T03:26:39.973 回答