作为用户定义的错误消息的异常中的SQL错误消息

时间:2015-01-18 02:59:57

标签: sql sql-server vb.net

我的桌子有以下设计:

tbl_property 
 Fields: property_id(Primary Key),property_name and fpp_id(Foreign Key From another Table tbl_fpp)

tbl_fpp
 Fields: fpp_id(primary_key),fpp_name

我已将行插入两个表格。

每次我插入tbl_property时,我都会从另一张表中获得fpp_id

我想在我的Visual Basic应用程序中向用户抛出一个异常,如果我删除table_fpp记录,如果在tbl_property中使用/引用该记录,那么我将提示用户消息就像。 “你无法删除FPP,因为它在其他记录中使用。”否则,如果未引用table_fpp,它将删除{{1}}的记录?

1 个答案:

答案 0 :(得分:0)

RAISERROR (N' You cannot delete an FPP because it is used in other record.' , -- Message text.
       10, -- Severity,
       1, -- State)

您可以在此处找到更多详细信息 http://msdn.microsoft.com/en-us/library/ms178592.aspx

相关问题