sql命令问题 [英] probleam with sql command

查看:77
本文介绍了sql命令问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hai我的sql命令有问题要更新.请告诉我我如何能够纠正我的命令.这里是可能的代码



Hai i got a probleam with my sql command for update. Please advice me how i able to correct my command .Here is may code



Try
            Connect = New OleDbConnection("Provider=SQLOLEDB ;Data Source=Danawa;Initial Catalog=Store;Integrated Security=SSPI ")
            Connect.Open()
            cmd = New OleDbCommand  ("UPDATE ItemIn SET Itemquantity= Itemquantity - '" & ItemquantityTextBox.Text & "AND" & "'Total= Total -'" & total.Text & "'WHERE ItemName= '" & ItemNameComboBox.Text & "' ", Connect) / i got an error in this line
            ra = cmd.ExecuteNonQuery()
Catch ex As Exception
            MsgBox(ex.Message)
        End Try
        MsgBox(" Purchase Successfull ", MsgBoxStyle.Information)
        Connect.Close()

推荐答案

使用以下查询,将为您提供帮助:
Use the following query, this will help you:
"UPDATE ItemIn SET Itemquantity = Itemquantity - " & ItemquantityTextBox.Text & ", Total= Total - " & total.Text & " WHERE ItemName= '" & ItemNameComboBox.Text & "' "


查看您的SQL命令,我猜测Itemquantity和Total是数字而不是VarChars.因此,您的解决方案以及所建议的其他解决方案均无效,因为您要从数字中减去字符串(ItemquantityTextbox.Text和total.Text).
Looking at your sql command, I''m guessing that Itemquantity and Total are Numbers instead of VarChars. So, your solution, as well as the other suggested, won''t work, since you''re deducting a string (ItemquantityTextbox.Text and total.Text) from a number.


一次替换一次
replace with this one once
cmd = New OleDbCommand  ("UPDATE ItemIn SET Itemquantity= Itemquantity - ''" & ItemquantityTextBox.Text & "''," & "Total= Total -''" & total.Text & "'' WHERE ItemName= ''" & ItemNameComboBox.Text & "'' ", Connect)


这篇关于sql命令问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆