这段代码把数据从 表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