DataTables("表A").DataRows.Clear DataTables("表A").StopRedraw() For i As Integer = 0 To 5000 Dim dr As DataRow = DataTables("表A").AddNew dr("第一列")= "aa" & i dr("第二列")= "bb1" & i Next DataTables("表A").ResumeRedraw()
DataTables("表B").DataRows.Clear DataTables("表B").StopRedraw() For i As Integer = 0 To 80000 Dim dr As DataRow = DataTables("表B").AddNew dr("第一列")= "aa" & i dr("第二列")= "bb1" & i Next DataTables("表B").ResumeRedraw() MessageBox.show("模拟数据完成")
Dim zd1 As new Dictionary(of String,DataRow) Dim zd2 As new Dictionary(of String,DataRow) For Each dr As DataRow In DataTables("表A").DataRows zd1.Add(dr("第一列"),dr) Next For Each dr As DataRow In DataTables("表B").DataRows zd2.Add(dr("第一列"),dr) Next
For Each str As String In zd1.Keys If zd2.ContainsKey(str) Then zd2(str)("第三列")= zd1(str)("第二列") '赋值 End If Next
MessageBox.show("数据复制完成")
|