以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 更新数据 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=139502) |
|
-- 作者:北狐 -- 发布时间:2019/8/14 10:56:00 -- 更新数据 Dim cwrb As New SQLCommand \'可复核的销售单号 Dim rb As DataTable cwrb.CommandText = " 从内部表查询按条件过滤出可复核的销售单号" rb = cwrb.ExecuteReader() Dim dt As DataTable Dim cmd As New SQLCommand cmd.C \'数据库为SQL2008 cmd.CommandText = " 查询 smartID,checked From {销售单} Where smartID = (" & rb & ")" \'注意要包括主键列 dt = cmd.ExecuteReader(True) \'注意可选参数设置为True For Each dr As DataRow In dt.DataRows dr("checked") = True Next dt.Save() 以上代码执行错误 需求为:根据内部表查询出来可复核的销售单号,更新后台数据中同单号的数据行的checked字段 请问老师是那里错了或者有其他方法实现根据内部表的查询结果更新后台数据
[此贴子已经被作者于2019/8/14 11:03:47编辑过]
|
|
-- 作者:有点蓝 -- 发布时间:2019/8/14 11:28:00 -- cmd.CommandText = " 查询 smartID,checked From {销售单} Where smartID = (" & rb.GetComboListString("smartID").Replace("|",",") & ")" |
|
-- 作者:北狐 -- 发布时间:2019/8/14 12:50:00 -- 老师改后报错如下 .NET Framework 版本:2.0.50727.8806 Foxtable 版本:2018.10.9.1 错误所在事件: 详细错误信息: \',\' 附近有语法错误。 以下是代码 Dim cwrb As New SQLCommand \'可复核的销售单号 Dim rb As DataTable cwrb.CommandText = "查询 本单单号 From {销售主表} where 是否检查=True and 本单单号 NOT in (查询 本单单号 From {单据检查异常情况})" rb = cwrb.ExecuteReader() Dim dt As DataTable Dim cmd As New SQLCommand cmd.C \'数据库为SQL2008 cmd.CommandText = "查询 smartID,checked From {销售单} Where smartID = (" & rb.GetComboListString("本单单号").Replace("|",",") & ")" \'注意要包括主键列 dt = cmd.ExecuteReader(True) \'注意可选参数设置为True For Each dr As DataRow In dt.DataRows dr("checked") = True Next dt.Save() |
|
-- 作者:有点蓝 -- 发布时间:2019/8/14 13:43:00 -- cmd.CommandText = "查询 smartID,checked From {销售单} Where smartID = (\'" & rb.GetComboListString("本单单号").Replace("|","\',\'") & "\')" |
|
-- 作者:北狐 -- 发布时间:2019/8/14 14:18:00 -- 代码替换后,不报错,但后台数据库的数据没有更新 |
|
-- 作者:有点蓝 -- 发布时间:2019/8/14 14:23:00 -- 把SQL放到后台数据库查询有没有符合条件的数据 |
|
-- 作者:北狐 -- 发布时间:2019/8/14 14:29:00 -- 没有符合的数据出来,用内部表试了,也没数据出来 [此贴子已经被作者于2019/8/14 14:30:38编辑过]
|
|
-- 作者:有点蓝 -- 发布时间:2019/8/14 14:36:00 -- 说明查询条件有问题 |
|
-- 作者:北狐 -- 发布时间:2019/8/14 14:40:00 -- 查询 smartID,checked From {销售单} Where smartID =\'XS1811-0068\' (这个可以查询到) 查询 smartID,checked From {销售单} Where smartID =(\'XS1811-0068,XS1905-1406,XS1906-0048\') (这个查询不到) 查询 smartID,checked From {销售单} Where smartID =(\'XS1811-0068\',\'XS1905-1406\',\'XS1906-0048\') (这个查询不到) 查询 smartID,checked From {销售单} Where smartID in (\'XS1811-0068\',\'XS1905-1406\',\'XS1906-0048\') (这个能查询到) 下面对应的要怎么改,自己改成这样还是不行
[此贴子已经被作者于2019/8/14 17:43:26编辑过]
|
|
-- 作者:北狐 -- 发布时间:2023/6/6 18:16:00 -- 数据更新 Jb18.AddExp("系统单号", "R04_MaterialsAllocation.smartID", True) Jb18.AddExp("单内序号", "1") Jb18.AddExp("工费单号", "R04_MaterialsAllocation.smartID", True) Jb18.AddExp("领料单号", "R04_MaterialsAllocation.smartID", True) \'Jb18.AddExp("产品成色", "\'\'") Jb18.AddExp("比较成色", "R02_SilverStyle.materialName", True) Jb18.AddExp("比较银重", "-sum(isnull(weight,0))") Jb18.AddExp("产品件数", "0") Jb18.AddExp("产品净银重", "0 * 0.00001") Jb18.AddExp("备注", "R04_MaterialsAllocation.outboundWarehouseName", True) \'Jb18.AddExp("实领料成色", "R02_SilverStyle.materialName ", True) Jb18.AddExp("实领料银重", "-sum(isnull(weight,0))") Jb18.AddExp("实工费", "0 * 0.00001") If e.Sender.Name = "Button3" Then Jb18.Filter = "convert(nvarchar(10),R04_MaterialsAllocation.smartDate,121)>=\'" & StartDate & "\' And convert(nvarchar(10), R04_MaterialsAllocation.smartDate,121)<=\'" & LastDay & "\' and R02_Customer. customerCode=\'" & cmdCustomerCode & "\' And R04_MaterialsAllocation.audited = \'true\'" \'加载数据时用 Else If e.Sender.Name = "Button06" Then Jb18.Filter = "R02_Customer. customerCode=\'" & cmdCustomerCode & "\' and R04_MaterialsAllocation.smartID in " & s & " and R04_MaterialsAllocation.audited=\'true\'" \'审核时用 End If End If \'组合jb1 \'采购入库的产品净银重 jb1.Merge(jb2) \'组合jb2 \'领料出库领料重 jb1.Merge(jb3) \'组合jb3 \'半成品入库的产品净银重 jb1.Merge(jb4) \'组合jb4 \'报废退货单的产品净银重 jb1.Merge(jb5) \'组合jb5 \'报废退货单的领料重 jb1.Merge(jb6) \'组合jb6 \'半成品入库的实工费 jb1.Merge(jb7) \'组合jb7 \'委外入库的实工费 jb1.Merge(jb8) \'组合jb8 \'返修入库的实工费 jb1.Merge(jb9) \'组合jb9 \'报废退货的实工费 jb1.Merge(jb10) \'组合jb10 \'付款单的实工费 jb1.Merge(jb11) \'组合jb11 \'往来费用单的实工费 jb1.Merge(jb12) \'组合jb12 \'材料入库的实工费 jb1.Merge(jb13) \'组合jb13 \'采购成品入库的实工费 jb1.Merge(jb14) \'组合jb14 \'材料入库的领料重 jb1.Merge(jb15) \'组合jb15 \'调拨出库领料重 jb1.Merge(jb16) \'组合jb16 \'返修退厂的实工费 jb1.Merge(jb17) \'组合jb17 \'旧料回收的领料重 jb1.Merge(jb18) \'组合jb18 \'\'调拨入库领料重 Dim dt As DataTable dt = jb1.Build(True) Dim sCols() As String = {"系统单号", "单内序号", "类型", "单据类型", "比较成色", "比较银重", "比较工费", "供应商代码", "供应商名称", "本单日期", "工费单号", "领料单号", "实工费", "产品件数", "产品净银重", "实领料银重", "备注"} Dim dCols() As String = {"ID", "number", "kind", "tableName", "contrastmaterialName" , "contrastweight", "contrastAmount", "customerCode", "customerName", "smartDate", "factoryID", "sourceID", For Each dr As DataRow In dt.DataRows \'填充数据 If DataTables("R03_payable_Detail").Find("customerCode= \'" & dr("供应商代码") & "\' and kind = \'" & dr("类型") & "\' and ID = \'" & dr("系统单号") & "\'And number = \'" & dr("单内序号") & "\' And c And c And c ") Is Nothing Then Dim nr As DataRow = DataTables("应付副表本地表").AddNew() For i As Integer = 0 To sCols.Length - 1 nr(dCols(i)) = dr(sCols(i)) Next End If Next 老师,以上代码,在填充数据代码段耗时很长,导致界面闪退,有什么方法优化吗?上面查询结果也只有100多行 [此贴子已经被作者于2023/6/6 18:21:06编辑过]
|