问题描述
我想要处理从网格视图中删除2个与另一个表有关系的表格
当我想删除第一个表格中的行时
产生的错误
DELETE语句与REFERENCE约束FK_TryIt_GuestsTable冲突。冲突发生在数据库Tourist,表dbo.TryIt,列'BookingNo'中。
声明已被终止。
所以我想创建消息,当我想删除row&此行在另一个表的行中有另一个值
(((您必须删除与此客户相关的第二个表中的所有预订)))
第一张桌子:
IDBooking(PK)类型宾客酒店地址
第二桌
ID(PK)IdBooking(FK)数字夜数房间
第一张桌子:
IDBooking(PK)类型宾客酒店地址
1
2
3
4
第二桌
ID(PK)IdBooking(FK)编号夜间号码房间
1 1
2 1
3 1
4 2
5 2
6 2
7 2
8 3
----------------
如果我想删除第一个表中的第4行我可以
但是
如果我想删除第一个表中的第1行我必须
删除第二张表中的行(1-2-3)
i希望handel这个错误不会出现在客户端
I Want handle Delete from Grid view 2 tables that have relationship with another table
when i want to delete row from the first table
an error accrued
The DELETE statement conflicted with the REFERENCE constraint "FK_TryIt_GuestsTable". The conflict occurred in database "Tourist", table "dbo.TryIt", column 'BookingNo'. The statement has been terminated.
so i want to create message when i want to delete row & this row have another values in rows of another table
(((you must delete all Booking in the Second table that related with this Client )))
first table :
IDBooking (P.K) Type Guest Hotel Address
Second Table
ID(P.K) IdBooking (F.K) Number Night Number Rooms
first table :
IDBooking (P.K) Type Guest Hotel Address 1 2 3 4
Second Table
ID(P.K) IdBooking (F.K) Number Night Number Rooms 1 1 2 1 3 1 4 2 5 2 6 2 7 2 8 3
----------------
if i want to delete the row 4 in the First table i can
but
if i want to delete the row 1 in the First table i Must
delete Rows(1-2-3) in the Second Table
i want to handel this error to dont appear to the client
这篇关于handle从Grid视图中删除有2个表机智关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!