以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 用数据库组件更新数据的问题 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=188104) |
-- 作者:HANZHIGANG -- 发布时间:2023/9/1 14:45:00 -- 用数据库组件更新数据的问题 Dim dlg As New OpenFileDialog dlg.Filter = "Excel文件|*.xls;*.xlsx" If dlg.ShowDialog = DialogResult.OK Then Dim Book As New XLS.Book(dlg.FileName) Dim Sheet As XLS.Sheet = Book.Sheets(0) For n As Integer = 1 To Sheet.Rows.Count - 1 Dim db = HySql.DataBaseFactory.CreateDatabase() Dim Sql = "se lect * from 运单管理 where [上游客户] = \'" & sheet(n, 0).Value & "\' And [商品车] = \'" & sheet(n, 1).Value & "\' And [VIN码] = \'" & sheet(n, 2).Value & "\' And [上游动态] = \'" & sheet(n, 3).Value & "\' And [二次] = 0 and [返单上游] = 0 " Dim dt As System.Data.DataTable = db.ExecuteDataSet(Sql).Tables(0) dt.TableName = "运单管理" dt.Rows(0)("返单上游") = 1 dt.Rows(0)("返单上游号") = Tables ("返单上游").Current ("返单上游号") dt.Rows(0)("返单上游操作员") = Tables ("返单上游").Current ("操作员") dt.Rows(0)("返单上游日期") = Tables ("返单上游").Current ("操作日期") db.UpdateDataTable(dt) Next Tables("返单上游_Table1").DataTable.Load 以上代码执行到dt.Rows(0)("返单上游") = 1这句时,会出现错误提示: 在位置 0 处没有任何行。
|
-- 作者:有点蓝 -- 发布时间:2023/9/1 14:49:00 -- 没有查询到符合条件的数据,判断一下 Dim dt As System.Data.DataTable = db.ExecuteDataSet(Sql).Tables(0) if dt.rows.count > 0 then dt.TableName = "运单管理" dt.Rows(0)("返单上游") = 1 dt.Rows(0)("返单上游号") = Tables ("返单上游").Current ("返单上游号") ……
|