数据表我有
EmpID | EmpName | Values | Rowindex _______ _______ _______ _______ 1 a 10 0 2 b 10 1 3 c 10 2 4 d 10 3 5 e 10 4 6 f 10 5 7 g 10 6 8 h 10 7 9 i 10 8
我需要的数据表是
数据表1:
EmpID | EmpName | Values | Rowindex _______ _______ _______ _______ 1 a 10 0 2 b 10 1 3 c 10 2 4 d 10 3 5 e 10 4
数据表2
EmpID | EmpName | Values | Rowindex _______ _______ _______ _______ 6 f 10 0 7 g 10 1 8 h 10 2 9 i 10 3
要拆分的条件:
P.s:我知道要根据列值进行拆分。不知道在计算后分裂。
根据Columnvalues编码拆分:
RequestDS = MYDataset
Dim dsTablesById As New DataSet()
For Each row As DataRow In RequestDS.Tables(0).Rows
Dim ID As String = row("ID").ToString()
If Not dsTablesById.Tables.Contains(ID) Then
dsTablesById.Tables.Add(ID)
For Each col As DataColumn In RequestDS.Tables(0).Columns
dsTablesById.Tables(ID).Columns.Add(col.ColumnName, col.DataType)
Next
End If
dsTablesById.Tables(ID).Rows.Add(row.ItemArray)
dsTablesById.Tables(ID).AcceptChanges()
ViewState("TableDataset") = dsTablesById
Next
答案 0 :(得分:1)
Dim ID As String = row("ID").ToString()
应该是
Dim ID As String = (row("ID") mod 5).ToString()
并在添加行之前执行以下操作:
row.ItemArray(3) = dsTablesById.Tables(ID).Rows.Count