Foxtable(狐表)用户栏目专家坐堂 → 复制代码的区别


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

主题:复制代码的区别

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


加好友 发短信
等级:小狐 帖子:337 积分:3225 威望:0 精华:0 注册:2020/2/25 23:12:00
复制代码的区别  发帖心情 Post By:2021/8/9 22:05:00 [显示全部帖子]

   这段代码把数据从 表A复制到A1
 For Each dr1 As DataRow In DataTables("表A").datarows
        Dim dr2 As DataRow = DataTables("表A1"). sqlfind("编码='" & dr1("编码") & "'")
        If dr2 Is Nothing Then
           dr2 =  DataTables("表A1").AddNew()
            For Each dc As DataCol In DataTables("表A").DataCols
               If  DataTables("表A1").DataCols.Contains(dc.name)  Then
                    If dc.Expression = "" Then  
                    If dr1.IsNull(dc.name) =False Then 
                        dr2(dc.Name) = dr1(dc.name)

End If
End If
 End If
End If
   Next
NEXT


下面 这段代码把选中的数据从表A1复制到A,我发现 第一段效率明显比第二段代码高,请问第二段应该怎么加速?

Dim t As Table = Tables("表A1")

Dim a1 As Integer
For i As Integer = t.TopPosition To t.BottomPosition
Dim dr2 As DataRow  =  DataTables("表A").AddNew()
    For Each dc As DataCol In DataTables("表A1").datacols        
    If  DataTables("表A").DataCols.Contains(dc.name)   Then   
    If dc.Expression = "" Then
   If t.Rows(i).IsNull(dc.name) =False Then

    dr2(dc.Name) = t.Rows(i)(dc.name)



  End If
    End If
End If
 Next
        
Next


 回到顶部