473,586 Members | 2,620 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Cl ear() ' where ds is the application DataSet
ds.Tables("tabl e1").Clear()

but I get the exception:

"An unhandled exception of type 'System.Argumen tException' 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 3099
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.C lear() ' where ds is the application DataSet
ds.Tables("tab le1").Clear()

but I get the exception:

"An unhandled exception of type 'System.Argumen tException' occurred in
system.data.dl l
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.Cl ear() ' where ds is the application DataSet
ds.Tables("tabl e1").Clear()

but I get the exception:

"An unhandled exception of type 'System.Argumen tException' 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*******@gmai l.comwrote in message
news:c7******** *************** ***@news.micros oft.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.C lear() ' where ds is the application DataSet
ds.Tables("tab le1").Clear()

but I get the exception:

"An unhandled exception of type 'System.Argumen tException' occurred in
system.data.dl l
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**@technetce nter.comwrote in message
news:oO******** *********@bigne ws4.bellsouth.n et...
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("ta ble1").Clear()

but I get the exception:

"An unhandled exception of type 'System.Argumen tException' occurred in
system.data.d ll
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("Tabl e1").Constraint s.Clear()

Thanks in advance

Geoff

"G .Net" <no********@ema il.comwrote in message
news:hp******** *************** *******@pipex.n et...
Hi T

Could you tell me how to remove the indexes?

Geoff

"tomb" <to**@technetce nter.comwrote in message
news:oO******** *********@bigne ws4.bellsouth.n et...
>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("t able1").Clear()

but I get the exception:

"An unhandled exception of type 'System.Argumen tException' 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
1784
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
6996
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
1797
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 after running the code the relations don't show in the relations window. However when I enter data in an underlying table I get referential integrity...
1
5124
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" ds.Tables(2).TableName = "MaterialSummary" ds.Tables(3).TableName = "ItemUsage" ds.Tables(5).TableName = "UsageSummary"
2
2862
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 # of tables and #relations increase or decrease So I can just pass any dataset and walk thru the rows?? Thanks
2
2485
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 summarize all the info being passed
4
3459
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 Relations.Clear() I still get excecptions, such as: Cannot remove ForeignKeyConstraint - remove the constraint first
2
342
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
3660
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) and the 'employee name'. There is another table which assigns an ID to the Shifts, i.e. 1,2 and 3 for morn, eve & night shifts respectively. From...
0
7912
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8202
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7959
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8216
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6614
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5710
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3865
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2345
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1449
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.