什麼是這個代碼錯誤的查詢,錯誤
String updateCmd = String.Format(@"UPDATE [admins]
SET [authority type] = '{0}',
SET [signature] = N'{1}',
SET [message] = N'{2}'
WHERE '{3}'", authorityType, signature, msg, condition);
什麼是這個代碼錯誤的查詢,錯誤
String updateCmd = String.Format(@"UPDATE [admins]
SET [authority type] = '{0}',
SET [signature] = N'{1}',
SET [message] = N'{2}'
WHERE '{3}'", authorityType, signature, msg, condition);
錯誤的事情,你應該只UPDATE
語句中使用一個SET
條款「附近的SET語句語法錯誤」。
UPDATE [admins]
SET [authority type] = '{0}',
[signature] = N'{1}',
[message] = N'{2}'
WHERE '{3}'
一兩件事,請做參數化查詢以避免SQL Injection
。使用Command
對象。
不要重複SET
String updateCmd = String.Format("UPDATE [admins] SET [authority type] = '{0}',
[signature] = N'{1}', [message] = N'{2}' WHERE '{3}'",
authorityType, signature, msg, condition);
你不需要多集只有一個。
非常感謝:)你是我的男人:) – 2013-02-08 14:22:31
不客氣':D' – 2013-02-08 14:23:57