SQL delete command?

后端 未结 7 2228
日久生厌
日久生厌 2020-12-18 02:34

I am having trouble with a simple DELETE statement in SQL with unexpected results , it seems to add the word to the list??. Must be something silly!. but i cannot see it , t

7条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-18 03:23

    SqlCommand Command = new SqlCommand(
                       "DELETE FROM excludes WHERE word='@word'" +
                         conn);
    

    should be replaced with

    SqlCommand Command = new SqlCommand(
                       "DELETE FROM excludes WHERE word='@word'",
                         conn);
    

    Also try by removing single quotes as suggested by others like this

    SqlCommand Command = new SqlCommand(
                       "DELETE FROM excludes WHERE word=@word",
                         conn);
    

提交回复
热议问题