Dim Cols3() As String = {"产品编号", "品名"}
Dim Cols4() As String = { "产品编号", "品名"}
For Each dr3 As DataRow In DataTables("窗口_Table3").Select("启用状态='启用'") '
Dim dr4 As Row = Tables("窗口_Table1").AddNew() '
For r As Integer = 0 To Cols3.Length - 1
dr4(Cols4(r)) = dr3(Cols3(r))
Next
Next
上面代码,执行后,会重复的复制数据。
需求:如果没旧数据,只复制启用状态='启用,而且数据不重复,如果存在旧数据,则忽略,退出,如何实现?
先使用find查询一下是否有相同编号的数据,没有再
AddNew
Dim nma() As String = {"产品编号", "品名"}'
Dim nmb() As String = {"产品编号", "品名"} '
For Each dr3 As DataRow In DataTables("窗口_Table3").Select("启用状态='启用'") '
If DataTables("销窗口_Table2").Find("产品编号 = '" & r("产品编号") & "'") Is Nothing Then '
Dim dr As Row = Tables("窗口_Table2").AddNew '
For i As Integer = 0 To nma.Length - 1
dr(nmb(i)) = r(nma(i))
Next
Else
MessageBox.Show("已经存在相同的行!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
Next
这种发现一条弹一次,手动确认,1万条有1000条重复,弹1000次,手动确认,那很不友好,如何做更好?
这种问用户,用户想怎么用?我的建议是完全没有必要弹窗