Home All Groups Group Topic Archive Search About

Q: deleting relations

Author
24 Aug 2006 3:11 PM
G .Net
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

Author
25 Aug 2006 12:50 AM
tomb
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:

Show quoteHide quote
>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
>
>

>
Author
25 Aug 2006 9:08 AM
G .Net
Hi T

Could you tell me how to remove the indexes?

Geoff

Show quoteHide quote
"tomb" <t***@technetcenter.com> wrote in message
news:oOrHg.15966$e9.2430@bignews4.bellsouth.net...
> 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
>>
>>
Author
25 Aug 2006 11:34 AM
G .Net
Basically, I need to know how to remove Unique and ForeignKey constraints.
The following line of code does not work:
ds.Tables("Table1").Constraints.Clear()

Thanks in advance

Geoff

Show quoteHide quote
"G .Net" <nodamnspam@email.com> wrote in message
news:hp6dnf3JQIeyInPZnZ2dnUVZ8s2dnZ2d@pipex.net...
> Hi T
>
> Could you tell me how to remove the indexes?
>
> Geoff
>
> "tomb" <t***@technetcenter.com> wrote in message
> news:oOrHg.15966$e9.2430@bignews4.bellsouth.net...
>> 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
>>>
>>>
>
>
Author
25 Aug 2006 2:21 AM
GhostInAK
Hello G .Net,

Goofball.  The relationships are there for a reason.  They define how you
are to interact with the data.  Follow their rules.

-Boo

Show quoteHide quote
> 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
>
Author
25 Aug 2006 9:07 AM
G .Net
Err, yes I know they're there for a reason ;) but I have my reasons for
doing this!

Geoff

Show quoteHide quote
"GhostInAK" <ghosti***@gmail.com> wrote in message
news:c71747b42d9b38c895c1474799fa@news.microsoft.com...
> Hello G .Net,
>
> Goofball.  The relationships are there for a reason.  They define how you
> are to interact with the data.  Follow their rules.
>
> -Boo
>
>> 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
>>
>
>