Foxtable(狐表)用户栏目专家坐堂 → 怪事怎么没有写入SQL表呢?


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

主题:怪事怎么没有写入SQL表呢?

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


加好友 发短信
等级:二尾狐 帖子:524 积分:3676 威望:0 精华:0 注册:2012/7/27 10:28:00
怪事怎么没有写入SQL表呢?  发帖心情 Post By:2019/3/20 13:56:00 [只看该作者]

Dim cmd As New SQLCommand
Dim dt As DataTable
cmd.C
cmd.CommandText = "S****T * From {客户资料}"
dt = cmd.ExecuteReader()


Dim db3 As WinForm.DropDownBox = e.Form.Controls("DropBox3")
Dim dzml3 As String = db3.text
If db3.value IsNot Nothing Then
    For Each f As String In FileSys.GetFiles(dzml3)
        If f.EndsWith(".txt") Then
            Dim strs As String = FileSys.ReadAllText(f,Encoding.Default)
            strs = strs.Replace(vblf,"")
            Dim rs() As String = strs.Split(vbcr)
            For i As Integer = 3 To rs.Length - 1
                Dim cs() As String = rs(i).replace("~~","~").Split("~")
                If cs.Length = 9 Then
                    If dt.Find("客户名称 = '" & cs(1) & "'and 税号 = '" & cs(3) & "'") Is Nothing Then
                        Dim dr As DataRow = dt.Addnew()
                        dr("客户名称") = cs(1)
                        dr("税号") = cs(3)
                        dr("地址电话") = cs(4)
                        dr("银行账号") = cs(5)
                    End If
                End If
            Next
        End If
    Next
    For Each f As String In FileSys.GetFiles(dzml3)
        If f.EndsWith(".xml") Then
            Dim txt As String = FileSys.ReadAllText(f, Encoding.Default)
            Dim xmlDoc As New System.XML.XmlDocument
            xmlDoc.Loadxml(txt.Trim)
            Dim ndList  = xmlDoc.GetElementsByTagName("Row")
            For Each dr As object In ndlist
                If dr.Attributes("NSRSBH") IsNot Nothing Then
                    Dim ndr As DataRow = dt.find("客户名称 = '" & dr.Attributes("MC").value  & "' and 税号 = '" & dr.Attributes("NSRSBH").value  & "'")
                    If ndr Is Nothing Then ndr = dt.addnew
                    ndr("客户名称") = dr.GetAttribute("MC")
                    ndr("税号") = dr.GetAttribute("NSRSBH")
                    ndr("地址电话") = dr.GetAttribute("DZ")
                    ndr("银行账号")  = dr.GetAttribute("YHZH")
                End If
            Next
        End If
    Next
    dt.DeleteFor("客户名称 Is Null   And 税号 Is Null   And 地址电话 Is Null  And 银行账号 Is Null ")
End If
If dt.HasChanges Then
    dt.Save
    dt.load()
    MessageBox.Show("客户信息导入完成")
Else
    MessageBox.Show("没有导入任何客户信息")
End If

 

能不能帮我看看怎么没有写入SQL的表中呢?


 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2019/3/20 14:48:00 [只看该作者]

dt = cmd.ExecuteReader()

 

改成

 

dt = cmd.ExecuteReader(true)


 回到顶部