Foxtable(狐表)用户栏目专家坐堂 → 导入数据问题


  共有3626人关注过本帖树形打印复制链接

主题:导入数据问题

帅哥哟,离线,有人找我吗?
季朝龙
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:幼狐 帖子:83 积分:918 威望:0 精华:0 注册:2019/9/20 14:29:00
导入数据问题  发帖心情 Post By: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

 回到顶部