I’m currently polishing a C# app in relation with a SQL-Server base.
It’s quite simple, you can add or remove entries from the SQL table via some fields from the application.
Question is :
On a Delete action, I’ve made this kind of query :
DELETE FROM table
WHERE ID = @ID
It deletes what I ask it to delete, BUT what if the query doesn’t find anything in the DB ?
How can I detect that ?
Because in this case, the application deletes nothing, and no exception is raised.
To make it short, I’d just like to tell the user that there’s nothing to delete in this case.
If you are using
SqlCommandobject, there is a method calledExecuteNonQuery. The method return how many rows are affected. So, zero means none.