-- 作者:hongyefor
-- 发布时间:2019/3/20 13:56:00
-- 怪事怎么没有写入SQL表呢?
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的表中呢?
|