Foxtable(狐表)用户栏目专家坐堂 → 多行多列的插入数据


  共有3853人关注过本帖树形打印复制链接

主题:多行多列的插入数据

帅哥哟,离线,有人找我吗?
lsy
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:5246 积分:33163 威望:0 精华:8 注册:2013/1/17 21:28:00
  发帖心情 Post By:2014/3/7 8:58:00 [显示全部帖子]

附件传不了,贴代码:

表A转表B:

DataTables("表B").DataRows.Clear()
For Each adr As DataRow In DataTables("表A").DataRows
    If adr.IsNull("姓名") = False Then
        For Each adc As DataCol In DataTables("表A").DataCols
            If adc.Name.StartsWith("工序") Then
                Dim bdr As DataRow = DataTables("表B").AddNew()
                bdr("姓名") = adr("姓名")
                bdr("工序") = adc.Name
                bdr("数量") = adr(adc.Name)
            End If
        Next
    End If
Next
DataTables("表B").Save()
MainTable = Tables("表B")

 

表B转表A(C):

DataTables("表C").DataRows.Clear()
Dim vals As List(Of String) = DataTables("表B").SQLGetValues("姓名","姓名 Is Not Null")
For Each val As String In vals
    Dim ddr As DataRow = DataTables("表C").AddNew()
    ddr("姓名") = val
    For Each bdr As DataRow In DataTables("表B").DataRows
        For Each ddc As DataCol In DataTables("表C").DataCols
            If ddc.Name = bdr("工序") AndAlso bdr("姓名") = val Then
                ddr(ddc.Name) = bdr("数量")
            End If
        Next
    Next
Next
Tables("表C").Sort = "姓名 Desc"
MainTable = Tables("表C")


 回到顶部