DeleteCommand in SqlDataSource using DetailsView

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • renatois
    New Member
    • Oct 2007
    • 16

    DeleteCommand in SqlDataSource using DetailsView

    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_Fab ricante". The conflict occurred in database "JanainaPapelar ia", table "dbo.Produt o", 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
  • kenobewan
    Recognized Expert Specialist
    • Dec 2006
    • 4871

    #2
    One way would be a try catch block, but if you provide more information an expert may suggest a more elegant way.

    Comment

    Working...