Sorry if this question is duplicate, but I have not found the answer. I want to check if a value of a column from a table is greater than 0, if not do something. The problem is that I do not know how to get the value from the table and check it.
My idea:
if(column table(Quantity) where ID=@ID >0)
{
Do something
}
I am using asp.net, C# and SQL. Here is some of my code: //This code is when an item is added to the table with the current id the number of the item is reduced by 1.
SqlCommand command = new SqlCommand("UPDATE Items SET Quantity=Quantity-1;
command.ExecuteNonQuery();
In the Items table I have the Quantity of the Item, so lets say 5 quantity of that specific item, and everytime that is added to the gridview is reduced by 1, I do not want it to be below 0. (Now with this code it goes below 0) I have the idea as I told you above but i do not know how to do it.
Anybody has an idea how to do it?