我有一个带有 CustomerID 的 table_Project(链接到 tbl_Customer)。在 tbl_Customer 我有 Customer_ID(作为密钥)和一些其他信息,如电话、电子邮件等。
要从 Gridview 中删除它,我使用此 DeleteCommand:
DeleteCommand="DELETE FROM [tbl_Customer] WHERE [Customer_ID] = @Customer_ID"
但它给了我以下错误:
The DELETE statement conflicted with the REFERENCE constraint "Klant_Relatie". The conflict occurred in database "Database_1", table "dbo.tbl_Project", column 'CustomerID'.
The statement has been terminated.
但是通过更新 CustomerInfo 我没有收到任何错误。我见过不同的 C# 解决方案,但我使用 .net
有任何想法吗?