开发者

Unexpected behavior when DELETEing from TABLE in SQL

开发者 https://www.devze.com 2023-03-31 04:07 出处:网络
I have done it before, but it\'s not working this time. All I\'m trying to do is delete an entry from a table, and as you can see, it is supposed to output \"ok\" if it succeeds, (and I have manually

I have done it before, but it's not working this time.

All I'm trying to do is delete an entry from a table, and as you can see, it is supposed to output "ok" if it succeeds, (and I have manually checked the querystring data and everything matches what its trying to delete, even all the conditions are also met), but it isn't deleting.

@{
    var message = "";
    try
    {
        var d = Database.Open("tgyytuyt");
        var query = "DELETE FROM Cart WHERE OrderId = '" + Request.QueryString["Value"] + "' AND UserId = '" + Request.QueryString["SubValue"] + "' AND PartNumber = '" + Request.QueryString["Final"] + "'";
        d.Ex开发者_运维百科ecute(query);

        message = "ok";
        //Response.Redirect("~/OSM/Default.cshtml");
    }
    catch(Exception ex)
    {
        message = ex.Message;
    }
}
<p>@message</p>

Is there something that I'm doing wrong that could be causing the item to not be deleted?


The most likely cause is, that there is no row in your database which meets the conditions of your where clause.

Check that first.

But without more information about the value of your querystring and your database setup its all guessing.

It might also be a trigger...


I don't know what your execute is doing, but you should be executing a non-query. You might want to check on that.

0

精彩评论

暂无评论...
验证码 换一张
取 消