以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 不重复行下自动拷贝问题 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=39717) |
||||
-- 作者:SZDVYE -- 发布时间:2013/8/30 22:54:00 -- 不重复行下自动拷贝问题 新增不重复的"单号"时,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 代码不工作,请老师改正.
|
||||
-- 作者:有点甜 -- 发布时间:2013/8/30 23:04:00 -- 如下代码 Select Case e.DataCol.name Case "单号" \'Dim cmd As New SQLCommand \'Dim dt As DataTable \'cmd.C \'cmd.CommandText = "Select * From {A} Where [单号] = \'" & e.NewValue & "\'" If e.DataTable.Find("单号= \'" & e.NewValue & "\' and _Identify <> " & e.DataRow("_Identify")) Is Nothing 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 Select |
||||
-- 作者:SZDVYE -- 发布时间:2013/8/31 9:22:00 -- 多了一行 \'cmd.C 问题解决了,谢谢您,有点甜老师.
|