-- 作者:晕了快扶我
-- 发布时间:2013/3/28 11:30:00
-- 求助,Update出错
DatarowDeleting 事件里的
Dim cmd3 As New SQLCommand cmd3.C cmd3.CommandText="select 当前库存 from {产品资料子表} Where 料号 = \'" & e.DataRow("OPN") & "\'" Dim kc As Integer = cmd3.ExecuteScalar DataTables("临时采购入库单子表").LoadFilter = "采购单号 = \'" & e.DataRow("采购单号") & "\' And OPN = \'" & e.DataRow("OPN") & "\'" DataTables("临时采购入库单子表").load Dim count As Integer = DataTables("临时采购入库单子表").DataRows.Count Dim dr As DataRow = DataTables("临时采购入库单子表").Find("[_Identify] = \'" & e.DataRow("_Identify") & "\'") Dim count1 As Integer = DataTables("采购入库单子表").Select("[_Identify] = \'" & e.DataRow("_Identify") & "\'And 采购单号 = \'" & e.DataRow("采购单号") & "\' And OPN = \'" & e.DataRow("OPN") & "\'").Count If dr Is Nothing AndAlso count = 0 Dim cmd As New SQLCommand cmd.C cmd.CommandText = "Update {采购订单子表} SET 未交数 = 未交数 + \'" & e.DataRow("数量_本次收") & "\'where 采购单号 = \'" & e.DataRow("采购单号") & "\' And 料号 = \'" & e.DataRow("OPN") & "\'" cmd.ExecuteNonQuery() ElseIf dr Is Nothing AndAlso count <> 0 For Each mr As DataRow In DataTables("临时采购入库单子表").DataRows mr("数量_累收数") = mr("数量_累收数") - e.DataRow("数量_本次收") mr("数量_未收数") = mr("数量_订单数") - mr("数量_累收数") For Each cr As DataRow In DataTables("采购入库单子表").Select("[_Identify] <> \'" & e.DataRow("_Identify") & "\' And 采购单号 = \'" & e.DataRow("采购单号") & "\' And OPN =\'" & e.DataRow("OPN") & "\'") cr("数量_累收数") = mr("数量_累收数") cr("数量_未收数") = mr("数量_未收数") Next Next Dim cmd As New SQLCommand cmd.C cmd.CommandText = "Update {采购订单子表} SET 未交数 = 未交数 + \'" & e.DataRow("数量_本次收") & "\'where 采购单号 = \'" & e.DataRow("采购单号") & "\' And 料号 = \'" & e.DataRow("OPN") & "\'" cmd.ExecuteNonQuery() ElseIf dr IsNot Nothing AndAlso count =1 Dim cmd As New SQLCommand cmd.C cmd.CommandText = "Update {采购订单子表} SET 未交数 = 未交数 + \'" & e.DataRow("数量_本次收") & "\'where 采购单号 = \'" & e.DataRow("采购单号") & "\' And 料号 = \'" & e.DataRow("OPN") & "\'" cmd.ExecuteNonQuery() Dim cmd2 As New SQLCommand cmd2.C cmd2.CommandText = "Update {产品资料子表} SET 当前库存 ="\' & kc - e.DataRow("数量_本次收") & "\' where 料号 = \'" & e.DataRow("OPN") & "\'" cmd2.ExecuteNonQuery() dr.Delete ElseIf dr IsNot Nothing AndAlso count >1 For Each mmr As DataRow In DataTables("临时采购入库单子表").DataRows mmr("数量_累收数") = DataTables("临时采购入库单子表").Compute("sum(数量_本次收)","[_Identify] <> \'" & e.DataRow("_Identify") & "\' And 采购单号 = \'" & e.DataRow("采购单号") & "\' And OPN = \'" & e.DataRow("OPN") & "\'") - e.DataRow("数量_本次收") mmr("数量_未收数") = mmr("数量_订单数") - mmr("数量_累收数") For Each ccr As DataRow In DataTables("采购入库单子表").Select("[_Identify] <> \'" & e.DataRow("_Identify") & "\' And 采购单号 = \'" & e.DataRow("采购单号") & "\' And OPN =\'" & e.DataRow("OPN") & "\'") ccr("数量_累收数") = mmr("数量_累收数") ccr("数量_未收数") = mmr("数量_未收数") Next Next Dim cmd As New SQLCommand cmd.C cmd.CommandText = "Update {采购订单子表} SET 未交数 = 未交数 + \'" & e.DataRow("数量_本次收") & "\'where 采购单号 = \'" & e.DataRow("采购单号") & "\' And 料号 = \'" & e.DataRow("OPN") & "\'" cmd.ExecuteNonQuery() Dim cmd2 As New SQLCommand cmd2.C cmd2.CommandText = "Update {产品资料子表} SET 当前库存 ="\' & kc - e.DataRow("数量_本次收") & "\' where 料号 = \'" & e.DataRow("OPN") & "\'" cmd2.ExecuteNonQuery() dr.Delete End If Dim cmd1 As New SQLCommand cmd1.C Dim temp As Integer = DataTables("临时采购入库单子表").Compute("sum(数量_未收数)","采购单号 = \'" & e.DataRow("采购单号") & "\'") + DataTables("采购入库单子表").Compute("sum(数量_未收数)","采购单号 = \'" & e.DataRow("采购单号") & "\'") If temp <>0 cmd1.CommandText ="Update {采购订单主表} SET 结案 = 0 Where 采购单号 = \'" & e.DataRow("采购单号") & "\'" cmd1.ExecuteNonQuery() ElseIf temp = 0 cmd1.CommandText ="Update {采购订单主表} SET 结案 = 1 Where 采购单号 = \'" & e.DataRow("采购单号") & "\'" cmd1.ExecuteNonQuery() End If
=========================
标红的代码出错,当前库存没有被刷新,出错提示如下:
.NET Framework 版本:2.0.50727.5466 Foxtable 版本:2012.11.29.1 错误所在事件: 详细错误信息: System.Data.OleDb.OleDbException: 第 1 行: \'=\' 附近有语法错误。 在 System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method) 在 System.Data.OleDb.OleDbCommand.ExecuteNonQuery() 在 Foxtable.SQLCommand.ExecuteNonQuery()
查了半天没查出问题来,求解
|