本文介绍了我在update语句中遇到错误语法错误,代码有什么问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

'更新adjustHead&AdjustmentDetails

'--------------------------------- ----------



'更新AdjustmentHead

strSql =UPDATE AdjustmentHead SET AdjustmentHead。[Adjustment + V] =&Forms![AdjustmentHead]![Adjustment + V]&,AdjustmentHead。[Adjustment-V] =&[Forms]![AdjustmentHead]![Adjustment-V2]&,AdjustmentHead.AdjustmentStatus = -1, AdjustmentHead.AdjTransactionID =&intTransactionID&,AdjustmentHead.AdjOrderID ='&strOrderID&'

strSql = strSql&WHERE(((AdjustmentHead.AdjustmentHeadID)= [Forms]![AdjustmentHead ]![AdjustmentHeadID]));

DoCmd.RunSQL strSql



'更新调整

strSql = UPDATE AdjustmentDetailsQ INNER JOIN Items ON AdjustmentDetailsQ.ItemID = Items.ItemID SET Items。[In] = [Items]![In] + [AdjustmentDetailsQ]![OrderQty],Items.Out = [Items]![Out] + [ AdjustmentDetailsQ]![IssueForLocal] + [AdjustmentDetailsQ]![ IssueForForign],Items.CIN = [Items]![CIN] + [AdjustmentDetailsQ]![OrderCQty],Items.COut = [Items]![COut] + [AdjustmentDetailsQ]![IssueForLocal]

strSql = strSql&WHERE((AdjustmentDetailsQ.AdjustmentHeadID)= [Forms]![AdjustmentHead]![AdjustmentHeadID])AND((AdjustmentDetailsQ.ActQOnH)不为空));

DoCmd .RunSQL strSql



strSql =UPDATE订单SET Orders.Adj = -1

strSql = strSql&WHERE((订单) .OrderID)喜欢'adj *'));

DoCmd.RunSQL strSql





strSql = UPDATE Transactions SET Transactions.AdjTrans = -1

strSql = strSql&WHERE((Transactions(Trans.TransactionNo)Like'* Adj *'));

DoCmd.RunSQL strSql





'结账表格



DoCmd.Close

'Updating AdjustmentHead & AdjustmentDetails
'-------------------------------------------

'update AdjustmentHead
strSql = "UPDATE AdjustmentHead SET AdjustmentHead.[Adjustment+V] = " & Forms![AdjustmentHead]![Adjustment+V] & ", AdjustmentHead.[Adjustment-V] = " & [Forms]![AdjustmentHead]![Adjustment-V2] & ", AdjustmentHead.AdjustmentStatus = -1, AdjustmentHead.AdjTransactionID = " & intTransactionID & ", AdjustmentHead.AdjOrderID = '" & strOrderID & "'"
strSql = strSql & " WHERE (((AdjustmentHead.AdjustmentHeadID)=[Forms]![AdjustmentHead]![AdjustmentHeadID]));"
DoCmd.RunSQL strSql

'update Adjustment
strSql = "UPDATE AdjustmentDetailsQ INNER JOIN Items ON AdjustmentDetailsQ.ItemID = Items.ItemID SET Items.[In] = [Items]![In]+[AdjustmentDetailsQ]![OrderQty], Items.Out = [Items]![Out]+[AdjustmentDetailsQ]![IssueForLocal]+[AdjustmentDetailsQ]![IssueForForign], Items.CIN = [Items]![CIN]+[AdjustmentDetailsQ]![OrderCQty], Items.COut = [Items]![COut]+[AdjustmentDetailsQ]![IssueForLocal]"
strSql = strSql & " WHERE (((AdjustmentDetailsQ.AdjustmentHeadID)=[Forms]![AdjustmentHead]![AdjustmentHeadID]) AND ((AdjustmentDetailsQ.ActQOnH) Is Not Null));"
DoCmd.RunSQL strSql

strSql = "UPDATE Orders SET Orders.Adj = -1"
strSql = strSql & " WHERE (((Orders.OrderID) Like 'adj*'));"
DoCmd.RunSQL strSql


strSql = "UPDATE Transactions SET Transactions.AdjTrans = -1"
strSql = strSql & " WHERE (((Transactions.TransactionNo) Like '*Adj*'));"
DoCmd.RunSQL strSql


'Closing Form

DoCmd.Close

推荐答案

String sql = "UPDATE table1 SET field1=@field1, field2=@field2...
...
cmd.Parameters.AddWithValue("@field1", txtField1.Text);
cmd.Parameters.AddWithValue("@field2", txtField2.Text);
...





完成后这样你的语法问题就会消失。



Once you have done it this way your syntax issue will be gone too.


这篇关于我在update语句中遇到错误语法错误,代码有什么问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-24 16:38