Foxtable(狐表)用户栏目专家坐堂 → 代码错在哪里?


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

主题:代码错在哪里?

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


加好友 发短信
等级:一尾狐 帖子:444 积分:4847 威望:0 精华:3 注册:2009/7/4 13:40:00
代码错在哪里?  发帖心情 Post By:2019/1/19 19:06:00 [显示全部帖子]

为什么下面的代码只能复制一条选中行的数据
With Tables("员工工资表")
    Dim n As Integer = .BottomPosition -.TopPosition
    Dim m As Integer = n+1
    Dim dr As Row = Tables("考勤表").AddNew(m)
    For i As Integer = .TopPosition To .BottomPosition
        dr("姓名") = Tables("员工工资表").Rows(i)("姓名")
    Next
End With

 回到顶部
帅哥哟,离线,有人找我吗?
ybmjy
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:一尾狐 帖子:444 积分:4847 威望:0 精华:3 注册:2009/7/4 13:40:00
  发帖心情 Post By:2019/1/19 20:23:00 [显示全部帖子]

搞定
Dim str As String = ""
For i As Integer = Tables("员工工资表").TopPosition To Tables("员工工资表").BottomPosition
    str = str & "," & Tables("员工工资表").Rows(i)("_Identify")
Next
Dim f As New Filler
f.SourceTable = DataTables("员工工资表") '指定数据来源
f.SourceCols = "姓名,工天" '指定数据来源列
f.DataTable = DataTables("考勤表") '指定数据接收表
f.DataCols = "姓名,合计" '指定数据接收列
f.Filter = "[_Identify] in (" & str.Trim(",") & ")"
f.Fill() '填充数据

 回到顶部
帅哥哟,离线,有人找我吗?
ybmjy
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:一尾狐 帖子:444 积分:4847 威望:0 精华:3 注册:2009/7/4 13:40:00
  发帖心情 Post By:2019/1/20 22:38:00 [显示全部帖子]

还是这样好点
Dim str As String = ""
Dim Filter As String
For i As Integer = Tables("员工工资表").TopPosition To Tables("员工工资表").BottomPosition
    str = str & "," & Tables("员工工资表").Rows(i)("_Identify")
Next
Dim Cols1() As String = {"姓名","工天"}
Dim Cols2() As String = {"姓名","合计"}
filter = "_Identify in (" & str.Trim(",") & ")"
For Each dr1  As DataRow In DataTables("员工工资表").Select(Filter)
    Dim dr2 As DataRow = DataTables("考勤表").AddNew
    For i As Integer = 0 To Cols1.Length -1
        dr2(Cols2(i)) = dr1(Cols1(i))
        
    Next
Next

 回到顶部