Show Custom Error message when Foreign Key Violation error occurs in C# .Net

Last Reply on May 11, 2015 09:11 AM By Mudassar

Posted on May 11, 2015 07:48 AM

I am using VS2010 and Sql Server 2000. There are two tables referenced by foreign key and I am not allowing Master record to be deleted, if record is present in child table. The scenario is working fine, but the problem is that when user will try to delete the record, I want to show custom error message to the user instead of sql exception. How can I do tha?

Posted on May 11, 2015 09:11 AM

Refer

http://stackoverflow.com/questions/2403348/how-can-i-know-if-an-sqlexception-was-thrown-because-of-foreign-key-violation