msdn 主题中的此 UPDATE 表语句是否正确
我在以下 msdn 主题中看到了这种类型的 UPDATE 语句(就像插入语句一样):
http: //msdn.microsoft.com/en-us/library/aa0416cz.aspx#Y2461
更新声明:-
adapter.UpdateCommand = New SqlCommand("UPDATE Customers " &
"(CustomerID, CompanyName) VALUES(@CustomerID, @CompanyName) " & _
"WHERE CustomerID = @oldCustomerID AND CompanyName = " &
"@oldCompanyName", connection)
此声明正确与否?
我尝试执行它,但它给出了语法错误。
I have seen this type of UPDATE statement (just like insert statement) in the following msdn topic:
http://msdn.microsoft.com/en-us/library/aa0416cz.aspx#Y2461
UPDATE statement:-
adapter.UpdateCommand = New SqlCommand("UPDATE Customers " &
"(CustomerID, CompanyName) VALUES(@CustomerID, @CompanyName) " & _
"WHERE CustomerID = @oldCustomerID AND CompanyName = " &
"@oldCompanyName", connection)
Is this statement correct or not?
I have tried executing it and it is giving syntax errors.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
不,它应该是:
或者为了完成您的示例代码,它应该是:
这是为您和这种情况提供的另一个参考: http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqldataadapter.updatecommand.aspx
No, it should be:
Or to be complete with your sample code, it should be:
Here is another reference for you and this situation: http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqldataadapter.updatecommand.aspx
该 SQL 对于 INSERT INTO 似乎是正确的,但对于 UPDATE 则不是正确的 它应该是这样的:
That SQL 就是所谓的参数化,因此这使得这段代码(在片段)非常重要:
That SQL appears to be correct for an
INSERT INTO
but not for anUPDATE
It should read:That SQL is what one would call paramaterized, so that makes this code (lower in the snippet) very important:
据我所知,语法无效。以下给出
'('附近的语法不正确。
我建议按照丹的回答。
As far as I can see the syntax is not valid. The following gives
Incorrect syntax near '('.
I suggest changing it as per Dan's answer.