以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 导入数据问题 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=145362) |
-- 作者:季朝龙 -- 发布时间:2020/1/17 10:32:00 -- 导入数据问题 狐狸爸爸,我设置了以下代码,当把find改成SQLfind就无法更新相同编号的数据了,想要实现后台数据比对之后再导入数据,代码该怎么修改呀。 Dim dlg As New OpenFileDialog \'定义一个新的OpenFileDialog dlg.Filter= "(*.*)|*.*" \'设置筛选器 If dlg.ShowDialog = DialogResult.Ok Then \'如果用户单击了确定按钮 Dim Book As New XLS.Book(dlg.FileName) Dim Sheet As XLS.Sheet = Book.Sheets("齐套信息") Tables("齐套信息").StopRedraw() Dim nms() As String = {"工单号","工单状态","产品料号","产品品名","产品规格","生产数量","异常_描述","异常_采购部回复","PN号","IQC在验量","预计齐套日期","备料料号","料件品名","料件规格","缺料","库存量","应发量","已发量","未发量","发货未收量"} For n As Integer = 1 To Sheet.Rows.Count -1 Dim bh As String = sheet(n,0).Text Dim bh1 As String = sheet(n,11).Text Dim dr As DataRow = DataTables("齐套信息").Find("工单号 = \'" & bh & "\' and 备料料号 = \'" & bh1 & "\'") If dr Is Nothing Then \'如果不存在同编号的订单 dr = DataTables("齐套信息").AddNew() End If For m As Integer = 0 To nms.Length - 1 dr(nms(m)) = Sheet(n,m).Value Next Next Tables("齐套信息").ResumeRedraw() End If |
-- 作者:有点蓝 -- 发布时间:2020/1/17 10:42:00 -- For n As Integer = 1 To Sheet.Rows.Count -1 Dim bh As String = sheet(n,0).Text Dim bh1 As String = sheet(n,11).Text Dim dr As DataRow = DataTables("齐套信息").SqlFind("工单号 = \'" & bh & "\' and 备料料号 = \'" & bh1 & "\'") If dr Is Nothing Then \'如果不存在同编号的订单 dr = DataTables("齐套信息").AddNew() End If For m As Integer = 0 To nms.Length - 1 dr(nms(m)) = Sheet(n,m).Value Next dr.save Next
|