以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 表间数据传递问题 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=92041) |
-- 作者:实话实说 -- 发布时间:2016/10/24 20:47:00 -- 表间数据传递问题 下面是表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 |
-- 作者:有点蓝 -- 发布时间:2016/10/24 21:44:00 -- If e.DataCol.Name = "选择" Then If e.DataRow("选择") = True Then Dim tr As DataRow =DataTables("表C").find("产品编号 =\'" & e.DataRow("产品编号") & "\'") If tr IsNot Nothing Then Dim nma() As String = {"A","B"} \'表C数据来源列 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)) = tr(nma(i)) Next End If End If End If
|
-- 作者:实话实说 -- 发布时间:2016/10/24 23:05:00 -- 2楼代码只能传递1条记录(已经搞定) [此贴子已经被作者于2016/10/25 7:22:47编辑过]
|