By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,361 Members | 1,700 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,361 IT Pros & Developers. It's quick & easy.

DeleteCommand in SqlDataSource using DetailsView

P: 16
DeleteCommand in SqlDataSource using DetailsView

Hi guys,
Figure that:
- I have two related tables by IDName:
1 - table Name (fields: IDName, Name)
2 - table Products (fields: IDProduct, IDName, Product)

On the page I have a DetailsView for inserting data on table Name and a GridView for editing and deleting records. In table Name, deleting and editing are ok but if I have a reference of IDName in table Product the deleting send me an error
---------------------------------------------
The DELETE statement conflicted with the REFERENCE constraint "FK_Produto_Fabricante". The conflict occurred in database "JanainaPapelaria", table "dbo.Produto", column 'fabCodigo'.
The statement has been terminated.
---------------------------------------------

Does anyone know how to treat this so when a record in table Name has a reference record in table Products the DeleteCommand of the SqlDataSource doesn´t trigger?

thanks a lot
Oct 25 '07 #1
Share this Question
Share on Google+
1 Reply


kenobewan
Expert 2.5K+
P: 4,871
One way would be a try catch block, but if you provide more information an expert may suggest a more elegant way.
Oct 25 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.