【发布时间】:2011-05-28 14:30:24
【问题描述】:
每当我在下面的CommandText 上调用“ExecuteNonQuery”命令时,我都会得到上面的 SQLException
myCommand.CommandText = "INSERT INTO fixtures (round_id, matchcode, date_utc, time_utc, date_london, time_london, team_A_id, team_A, team_A_country, team_B_id, team_B, team_B_country, status, gameweek, winner, fs_A, fs_B, hts_A, hts_B, ets_A, ets_B, ps_A, ps_B, last_updated) VALUES (" _
& round_id & "," & match_id & "," & date_utc & ",'" & time_utc & "'," & date_london & ",'" & time_london & "'," & team_A_id & ",'" & team_A_name & "','" & team_A_country & "'," & team_B_id & ",'" & team_B_name & "','" & _
team_B_country & "','" & status & "'," & gameweek & ",'" & winner & "'," & fs_A & "," & fs_B & "," & hts_A & "," & hts_B & "," & ets_A & "," & ets_B & "," & ps_A & "," & ps_B & "," & last_updated & ")"
但每当我删除最后一个表项 - “last_updated”时,错误就会消失。请帮我解决这个问题。 datetime字段有什么特殊处理吗???
感谢您的帮助
【问题讨论】:
-
为什么哦为什么人们仍然不使用参数化查询。你让你的生活变得非常困难,更不用说让自己面临 sql 注入攻击了。
-
请向我们展示所有文本的连接结果。答案可能很明显。
-
我知道 SQL 注入攻击以及何时接触到它们。没有条目不是来自表单上的文本框,它们都来自订阅的足球比赛的 xml 提要。所以没有注射的风险。无论如何,我使用了存储过程并且它有效。