SQL delete command?

后端 未结 7 1219
死守一世寂寞
死守一世寂寞 2020-12-18 02:59

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:26

    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);
    

提交回复
热议问题