以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 更新数据问题 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=194877) |
-- 作者:lrh9537 -- 发布时间:2025/1/24 16:37:00 -- 更新数据问题 Dim Cols1() As String = {"乡镇", "行政村", "总计"} Dim Cols2() As String = {"乡镇", "行政村", "总计"} For Each dr1 As DataRow In DataTables("分村统计表").Select("[乡镇] IS NOT NULL") Dim dr2 As DataRow = DataTables("分村统计表2").AddNew() For i As Integer = 0 To Cols1.Length - 1 dr2(Cols2(i)) = dr1(Cols1(i)) Next Next 修改为:如“分村统计表2”中已存在“乡镇", "行政村", "总计”,保持“分村统计表2”中的“乡镇", "行政村"不变也不新增,只更新表中的其他数据
|
-- 作者:有点蓝 -- 发布时间:2025/1/24 16:50:00 -- 先使用find查询一下,没有再新增:http://www.foxtable.com/webhelp/topics/0396.htm …… For Each dr1 As DataRow In DataTables("分村统计表").Select("[乡镇] IS NOT NULL") Dim dr2 As DataRow = DataTables("分村统计表2").find(“乡镇=\'" & dr1("乡镇") & "\' and 行政村=\'" & dr1("行政村") & "\') if dr2 is nothing then dr2 = DataTables("分村统计表2").AddNew() For i As Integer = 0 To Cols1.Length - 1 dr2(Cols2(i)) = dr1(Cols1(i)) Next ……
|