SQL delete command?

后端 未结 7 1224
死守一世寂寞
死守一世寂寞 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:25

    You can also try the following if you don't have access to some of the functionality prescribed above (due, I believe, to older versions of software):

    using (var connection = _sqlDbContext.CreatSqlConnection())
    {
        using (var sqlCommand = _sqlDbContext.CreateSqlCommand())
        {
            sqlCommand.Connection = connection;
            sqlCommand.CommandText = $"DELETE FROM excludes WHERE word = @word";
            sqlCommand.Parameters.Add(
                                _sqlDbContext.CreateParameterWithValue(sqlCommand, "@word", word));
            connection.Open();
            sqlCommand.ExecuteNonQuery();
        }
    }
    ...
    

    I'm an associate dev. Hence the "I believe" above.

提交回复
热议问题