以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- [求助]复制表的问题 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=136329) |
||
-- 作者:禾成 -- 发布时间:2019/6/11 15:02:00 -- [求助]复制表的问题 If e.DataCol.Name = "是否" AndAlso e.DataRow("是否") = True 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 End If 上面代码是A表有个逻辑列“是否” 如个=是则复制A表一到六列给B表 现在有个问题:逻辑列会重复操作,导致重复将数据复制到B表造成数据重复,如何解决?
[此贴子已经被作者于2019/6/11 15:01:57编辑过]
|
||
-- 作者:有点蓝 -- 发布时间:2019/6/11 20:23:00 -- 有没有关键的列?比如编号之类的,通过find查询一下表B是否有这个编号的数据,如果有就不添加:http://www.foxtable.com/webhelp/topics/0396.htm 或者判断是否有着6列值都一样的数据 Dim dr As DataRow = DataTables("B表").Find("一列 = \'" & e.DataRow("一列") & "\' and 二列 = \'" & e.DataRow("二列") & "\' and......")
|
||
-- 作者:禾成 -- 发布时间:2019/6/12 9:36:00 --
|
||
-- 作者:有点甜 -- 发布时间:2019/6/12 12:06:00 -- If e.DataCol.Name = "是否"
If e.DataRow("是否") = True 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 dr("第十列") = e.DataRow("_Identify") Else DataTables("B表").deletefor("第十列=\'" & e.DataRow("_Identify") & "\'") End If End If |
||
-- 作者:禾成 -- 发布时间:2019/6/15 20:26:00 -- 多谢蓝老师,受益了! |