以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  跨表统计代码出错  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=125491)

--  作者:ZJZK2018
--  发布时间:2018/9/29 13:59:00
--  跨表统计代码出错
Dim dt As DataTable = DataTables("年度社保库")
DataTables("社保年度汇总").DataRows.Clear()
Dim Arys As List(of String())
Arys = dt.GetValues("姓名|年度")
For Each Ary As String() In Arys
    Dim dr As DataRow = DataTables("社保年度汇总").AddNew()
    dr("姓名") = Ary(0)
    dr("年度") = Ary(1)
    For Each dc As DataCol In dt.DataCols
        If dc.IsNumeric AndAlso dc.Name <> "年度" Then
            If DataTables("社保年度汇总").DataCols.Contains(dc.Name) Then
                dr(dc.Name) = dt.Compute("Sum(dc.Name)","姓名 = \'" & Ary(0) & "\' And 年度 = " & Ary(1))
            End If
        End If
    Next
Next

错误提示:

图片点击可在新窗口打开查看此主题相关图片如下:550506.png
图片点击可在新窗口打开查看



--  作者:有点蓝
--  发布时间:2018/9/29 14:56:00
--  
dr(dc.Name) = dt.Compute("Sum(" & dc.Name & ")","姓名 = \'" & Ary(0) & "\' And 年度 = " & Ary(1))