答案 0 :(得分:0)
尝试以下代码:
try
{
//Your code block to delete the record.
}
catch(Exception ex)
{
if (ex.Message.ToLower().Contains("statement conflicted with the reference constraint"))
{
//Show custom error message as "need to delete parent value before delete this record."
}
}