473,395 Members | 1,677 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Q: deleting relations

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
Aug 24 '06 #1
5 3081
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

Aug 25 '06 #2
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

Aug 25 '06 #3
Err, yes I know they're there for a reason ;) but I have my reasons for
doing this!

Geoff

"GhostInAK" <gh*******@gmail.comwrote in message
news:c7**************************@news.microsoft.c om...
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


Aug 25 '06 #4
Hi T

Could you tell me how to remove the indexes?

Geoff

"tomb" <to**@technetcenter.comwrote in message
news:oO*****************@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


Aug 25 '06 #5
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

"G .Net" <no********@email.comwrote in message
news:hp******************************@pipex.net...
Hi T

Could you tell me how to remove the indexes?

Geoff

"tomb" <to**@technetcenter.comwrote in message
news:oO*****************@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



Aug 25 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Andreas Fromm | last post by:
Hi, I have The following situation: CREATE TABLE data1 ( id SERIAL PRIMARY KEY, data INTEGER ); CREATE TABLE data2 (
14
by: Matthew Wells | last post by:
I'm using this code to delete all relationships in my mdb file iFlag = 1 Do While iFlag <> 0 iFlag = 0 For Each rel In db.Relations db.Relations.Delete rel.Name iFlag = 1 Next rel Loop
1
by: Jef De Rycke | last post by:
Hi access group, I have written code to create relations between tables according to a corresponding relations information table. At first I thought my code was not working properly because...
1
by: Randy Fraser | last post by:
How do I create a relationship on muliple columns in an untyped dataset. Why does this not work. da.Fill(ds) ds.Tables(0).TableName = "DesignSummary" ds.Tables(1).TableName = "FormulaSummary"...
2
by: Joe | last post by:
Hi I have a dataset with 3 tables and 2 relations Is there a way to when I am at 1 row to tell if there is a relation on that row ??? I have the code hardcoded but try to make it work if the #...
2
by: Joe | last post by:
Hi I am going to receive a dataset downstream and I will not know the the fields number of field relations number of relations So I have to be flexible to take unknown data and be able to...
4
by: G .Net | last post by:
Hi I have a DataSet with several DataTables. I have set up relations between these tables. I want to delete all the tables and re-fill them. However, when I try to do so, even after using...
2
by: Nick 'The database Guy' | last post by:
Hello People, Does anyone know how to browse and delete folders in VBA? Thanks, Nick McMillen
11
by: shriil | last post by:
Hi I have this database that calculates and stores the incentive amount earned by employees of a particular department. Each record is entered by entering the Date, Shift (morn, eve, or night)...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.