Hi
I have created two tables Category(C_ID, C_Name) and Sub_category (S_ID,S_Name,C_ID[fk])
I have dispyed the data in the gridview using sql server configuration with enabled edit and delete options
Edit is working properly but when I try to delete the row it show Error message
The DELETE statement conflicted with the REFERENCE constraint "FK__sub_catego__C_ID__60083D91". The conflict occurred in database "master", table "dbo.sub_category", column 'C_ID'.
The statement has been terminated.
Kindly help me in solving this problem.Thanks
Kritika

Nilesh AvhadRank #3,587 · 406 reputationPosted Mar 21, 2014, 3:48 AM EDT
From which table you are displaying data in gridview? i.e you are fetching data from master table or detail table. If you are fetching data from master table i.e. from Category table and displaying it in grid with enable update and delete and trying to delete the data from Categry table then user usually face this type of error.
The error itself is saying that if you are deleting data directly from master table then it will not allow you to do that. Because the data related to that C_ID key is present in detail table so you can not do that.
The solution is that first delete the record from detail table an then try to delete from master table.
Hope this will clear your problem. If you need further help then reach to me here.
=======================================================================
Kindly mark as answer if it solves your problem.
Thanks..... Nilesh
kritika RanaRank #7,001 · 251 reputationPosted Mar 21, 2014, 4:11 AM EDT
It is working now. But I want to remove the records from the master table without deleting form referenced table.
Kindly let me know if this is possible and how.
Thanks
Nilesh AvhadRank #3,587 · 406 reputationPosted Mar 21, 2014, 4:44 AM EDT
It is not possible Kritika. But you can delete the record from the both tables at the same time.
to achieve this please refer the following link.
http://stackoverflow.com/questions/3656099/how-to-delete-rows-in-tables-that-contain-foreign-keys-to-other-tables