以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 如何通过第三个表的数据导入相关数据 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=126247) |
-- 作者:ZJZK2018 -- 发布时间:2018/10/17 14:26:00 -- 如何通过第三个表的数据导入相关数据 我有二个表“开标标录”和“标录明细”,要把“开标标录”的相关数据新增并导入到“标录明细”表中,但由于二个表的列名不同,需要第三个表进行指定哪个列名的相关数据导入到另一个表指定列名上,如何处理??谢谢!! |
-- 作者:有点甜 -- 发布时间:2018/10/17 14:45:00 -- Dim tb1 As Table = Tables("列名表") \'加载表 Dim tb2 As Table = Tables("开标标录") \'加载表 Dim tb3 As Table = Tables("标录明细") \'标录明细表 Dim dic As new Dictionary(of String, String) For Each dc As Col In tb2.Cols If dic.ContainsKey(dc.Caption) = False Then dic.Add(dc.Caption, dc.name) End If Next Dim dic1 As new Dictionary(of String, String) For Each r As Row In tb1.Rows If r("接收表列名") = Nothing Then dic1.add(dic(r("来源表列名")), dic(r("来源表列名"))) Else dic1.add(dic(r("来源表列名")), r("接收表列名")) End If Next For Each dr1 As DataRow In tb2.DataTable.Select("[投标企业] Is Not Null") Dim dr2 As Row = tb3.AddNew() For Each key As String In dic1.Keys If tb3.Cols.Contains(dic1(key)) Then dr2(dic1(key)) = dr1(key) End If Next Next |