奇怪的SQL语句,难道不认识减号???
Int32 iLastNum = iNum - iHidNum;
//更新最后剩余量
string strEXESQL = "Update Sale_Order_Detail Set LastNum=LastNum- " + iLastNum + " Where OrderCode= ' " + strOrderCode + " ' AND ProductType= ' " + strProductType + " ' ";
扑到最后的SQL语句为:
Update Sale_Order_Detail Set LastNum=LastNum--400 Where OrderCode= '11100120070225004 ' AND ProductType= 'SE-469 '
LastNum=LastNum--400 并没有认为是 LastNum=LastNum+400 所以iLastNum <0的时候运算出错
怎么解决啊
------解决方案--------------------加(-400),被注释了
------解决方案--------------------同意楼上
--在T-SQL中是注释符号
------解决方案--------------------“LastNum--400”明显出错,多了一个“-”符合。
------解决方案--------------------string strEXESQL = "Update Sale_Order_Detail Set LastNum=LastNum-( " + iLastNum + ") Where OrderCode= ' " + strOrderCode + " ' AND ProductType= ' " + strProductType + " ' ";
------解决方案--------------------用()号或加个空格就可.
如:
Set LastNum=LastNum- " + iLastNum