每當我呼籲以下CommandText
的「ExecuteNonQuery
」命令,我得到上面的SQLException的SQLException:不正確的語法附近「2」
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注入攻擊。 – RPM1984 2010-12-21 02:32:04
請向我們展示所有文本串聯的結果。答案可能很明顯。 – 2010-12-21 02:47:14
我知道有關SQL注入攻擊以及什麼時候暴露給他們。非條目不是來自表單上的文本框,它們全部來自訂閱的足球比賽的XML提要。所以沒有注射風險。無論如何,我已經使用存儲過程,它的工作。 – 2010-12-22 06:52:42