新增不重复的"单号"时,B表自动增加一行,并将单号内容自动拷到B表中,若新增重复"单号",不自动拷贝到B表代码为:
Select Case e.DataCol.name
Case
"单号"
Dim
cmd As New SQLCommand
Dim
dt As DataTable
cmd.ConnectionName = "Take
Over"
cmd.CommandText = "Select
* From {A} Where [单号] = '" & e.NewValue & "'"
dt
= DataTables("A")
If
dt.Find("单号= '" &
e.NewValue & "'")
Is Nothing Then
If
e.DataCol.Name = "单号" AndAlso e.DataRow.IsNull("单号") = False Then
Dim nma() As String = {"单号"} 'A表数据来源列
Dim nmb() As String = {"指令号"} '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
MainTable
=Tables("B")
End
If
End If
End Select
代码不工作,请老师改正.