I have a table with products and another with the category of that product. In the category table I have a detailsView with a delete button, and it deletes when a category is not associated with a product (from another table), that is when a category is associated with a product and gives the error, instead of the user viewing the I want to get an error message on a page or a label, something that the user can see because he can not delete the category.
error:
The DELETE statement conflicted with the REFERENCE constraint "FK_Products_Categories". The conflict occurred in database "C: \ USERS \ DOCUMENTS \ VISUAL STUDIO 2013 \ WEBSITES \ PROJECT \ APP_DATA \ DBTI2.MDF ", table" dbo.Products ", column 'CategoryID'. The statement has been terminated.