Re: Q: deleting relations

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



The exception is telling you to remove your indexes first - there is a foreign key index from the child table to the parent. Remove that first, then remove the relation.

T

G .Net wrote:

Hi

I'm hoping that somebody can help me with a fairly puzzling problem.

I've created some DataTables which have relations between them e.g. one to many. In the application, I want to remove entries from the table. To do this I obviously need to temporarily switch off the relations. In order to achieve this, I tried:

ds.Relations.Clear() ' where ds is the application DataSet
ds.Tables("table1").Clear()

but I get the exception:

"An unhandled exception of type 'System.ArgumentException' occurred in system.data.dll
Additional information: Cannot remove unique constraint 'Constraint1'. Remove foreign key constraint table1_table3' first."

What I don't understand is why the relations don't seem to have been removed.

Can anybody point me in the right direction i.e. how do I switch off the relations to allow the clearing of a table?

Many thanks in advance

Geoff




.



Relevant Pages

  • Re: Q: deleting relations
    ... foreign key index from the child table to the parent. ... this I obviously need to temporarily switch off the relations. ... "An unhandled exception of type 'System.ArgumentException' occurred in ... Cannot remove unique constraint 'Constraint1'. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Exception and Sql-Server
    ... from an exception (primary key, foreign key or any other constraint). ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: do task constraints constrain subtasks?
    ... communicate what is happening. ... realistic picture of what is meant to happen. ... I guess I take exception to the statement that, ... tasks under the summary there is an overall constraint. ...
    (microsoft.public.project)
  • RE: DataTable.RemoveRow
    ... I have retried to reproduce the contraint exception according to your ... the unique constraint only works ... constraint is violate, an ConstraintException is thrown. ... After the loop, all valid rows will be added to the ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Constraint Exception from Web Service
    ... capturing the constraint error in the web service and then threw it back to ... the page as a soap exception. ...
    (microsoft.public.dotnet.framework.webservices.enhancements)