下面是表A复制数据到表B的代码,【选择】列在表A。
我需要将表C的数据(不是表A)复制到表B,表A与表C通过【产品编号】关联,代码如何改?
If e.DataCol.Name = "选择" Then
If e.DataRow("选择") = True Then
Dim nma() As String = {"A","B"} '表A数据来源列
Dim nmb() As String = {"C","D"} '表B数据接收列
Dim dr As DataRow = DataTables("表B").AddNew
For i As Integer = 0 To nma.Length - 1
dr(nmb(i)) = e.DataRow(nma(i))
Next
For Each dc As DataCol In DataTables("表B").DataCols
If dc.name ="id" Then
dr("id") =e.DataRow("_identify")
Else
'dr(dc.Name) = e.DataRow(dc.Name)
dr("C") = e.DataRow("A")
dr("D") = e.DataRow("B")
End If
Next
Else
Dim tr As DataRow =DataTables("表B").find("id ="& e.DataRow("_identify"))
If tr IsNot Nothing Then
tr.delete()
End If
End If
End If