473,728 Members | 1,689 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Q: Deleting a table with constraints

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 ForeignKeyConst raint - remove the constraint first

when trying to remove a table.

Can anybody help???

Jul 5 '06 #1
4 3466
Lucky enough is it as that is.

You can (normally I have seen a situation that does that) not have children
without a parent.

Therefore you have first to delete all the childs before you can delete the
parent.

If you want to do it than to the database (maybe that is your question),
than you have to use this.
http://msdn2.microsoft.com/en-us/library/0f8054fy.aspx

First do the deleted children rows
Than the parent rows
Than the modified and added children.

Don't forget to do an acceptchanges on the original dataset.

You see than direct why is that acceptchanges.

I hope this helps,

Cor

"G .Net" <no********@ema il.comschreef in bericht
news:sP******** ************@pi pex.net...
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 ForeignKeyConst raint - remove the constraint first

when trying to remove a table.

Can anybody help???

Jul 5 '06 #2
Hi Cor

Thanks for that. I'll have a look.

However, I'm puzzled why clearning the relations doesn't solve it? Surely
that should make the tables seperate (i.e. with no relationships) so I can
simple do something like:

dt.Remove()

for any table. However, as I indicated earlier, this stil throws an
exception.
"Cor Ligthert [MVP]" <no************ @planet.nlwrote in message
news:uB******** ******@TK2MSFTN GP03.phx.gbl...
Lucky enough is it as that is.

You can (normally I have seen a situation that does that) not have
children without a parent.

Therefore you have first to delete all the childs before you can delete
the parent.

If you want to do it than to the database (maybe that is your question),
than you have to use this.
http://msdn2.microsoft.com/en-us/library/0f8054fy.aspx

First do the deleted children rows
Than the parent rows
Than the modified and added children.

Don't forget to do an acceptchanges on the original dataset.

You see than direct why is that acceptchanges.

I hope this helps,

Cor

"G .Net" <no********@ema il.comschreef in bericht
news:sP******** ************@pi pex.net...
>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 ForeignKeyConst raint - remove the constraint first

when trying to remove a table.

Can anybody help???


Jul 5 '06 #3
Did you figure out what the problem was? I'm running into the same
thing. I have a dataset with 2 tables in it. Clearing the relations
doesn't seem to do anything. Instead I can first clear the child
table, then clear the parent table. I can't remove the table from the
dataset however. I get the error 'Cannot remove table ... because it
is referenced in ForeignKeyConst raint ... Remove the constraint first.'

How can I remove the constraint? Clearing the relations doesn't do it.

Jesse.
G .Net wrote:
Hi Cor

Thanks for that. I'll have a look.

However, I'm puzzled why clearning the relations doesn't solve it? Surely
that should make the tables seperate (i.e. with no relationships) so I can
simple do something like:

dt.Remove()

for any table. However, as I indicated earlier, this stil throws an
exception.
"Cor Ligthert [MVP]" <no************ @planet.nlwrote in message
news:uB******** ******@TK2MSFTN GP03.phx.gbl...
Lucky enough is it as that is.

You can (normally I have seen a situation that does that) not have
children without a parent.

Therefore you have first to delete all the childs before you can delete
the parent.

If you want to do it than to the database (maybe that is your question),
than you have to use this.
http://msdn2.microsoft.com/en-us/library/0f8054fy.aspx

First do the deleted children rows
Than the parent rows
Than the modified and added children.

Don't forget to do an acceptchanges on the original dataset.

You see than direct why is that acceptchanges.

I hope this helps,

Cor

"G .Net" <no********@ema il.comschreef in bericht
news:sP******** ************@pi pex.net...
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 ForeignKeyConst raint - remove the constraint first

when trying to remove a table.

Can anybody help???
Jul 19 '06 #4
Nevermind, I figured it out. I had to remove the primary key
constraint AND the foreign key constraint, THEN clear the relations,
THEN I could remove the table.

ds.Tables("dt1" ).Constraints.R emoveAt(0)
ds.Tables("dt2" ).Constraints.R emoveAt(0)
ds.Relations.Cl ear()
dsOTTR.Tables.C lear()

Jesse wrote:
Did you figure out what the problem was? I'm running into the same
thing. I have a dataset with 2 tables in it. Clearing the relations
doesn't seem to do anything. Instead I can first clear the child
table, then clear the parent table. I can't remove the table from the
dataset however. I get the error 'Cannot remove table ... because it
is referenced in ForeignKeyConst raint ... Remove the constraint first.'

How can I remove the constraint? Clearing the relations doesn't do it.

Jesse.
G .Net wrote:
Hi Cor

Thanks for that. I'll have a look.

However, I'm puzzled why clearning the relations doesn't solve it? Surely
that should make the tables seperate (i.e. with no relationships) so I can
simple do something like:

dt.Remove()

for any table. However, as I indicated earlier, this stil throws an
exception.
"Cor Ligthert [MVP]" <no************ @planet.nlwrote in message
news:uB******** ******@TK2MSFTN GP03.phx.gbl...
Lucky enough is it as that is.
>
You can (normally I have seen a situation that does that) not have
children without a parent.
>
Therefore you have first to delete all the childs before you can delete
the parent.
>
If you want to do it than to the database (maybe that is your question),
than you have to use this.
http://msdn2.microsoft.com/en-us/library/0f8054fy.aspx
>
First do the deleted children rows
Than the parent rows
Than the modified and added children.
>
Don't forget to do an acceptchanges on the original dataset.
>
You see than direct why is that acceptchanges.
>
I hope this helps,
>
Cor
>
"G .Net" <no********@ema il.comschreef in bericht
news:sP******** ************@pi pex.net...
>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 ForeignKeyConst raint - remove the constraint first
>>
>when trying to remove a table.
>>
>Can anybody help???
>>
>>
>>
>
>
Jul 19 '06 #5

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

Similar topics

36
4652
by: toedipper | last post by:
Hello, I am designing a table of vehicle types, nothing special, just a list of unique vehicle types such as truck, lorry, bike, motor bike, plane, tractor etc etc For the table design I am proposing a single column table with a field name called vehicle_type and this will contain the vehicle type. Sot it will be
4
2036
by: harish | last post by:
DELETING 100 million from a table weekly SQl SERVER 2000 Hi All We have a table in SQL SERVER 2000 which has about 250 million records and this will be growing by 100 million every week. At a time the table should contain just 13 weeks of data. when the 14th week data needs to be loaded the first week's data has to be deleted. And this deletes 100 million every week, since the delete is taking lot
0
1418
by: Scott Ribe | last post by:
I've got a problem which I think may be a bug in Postgres, but I wonder if I'm missing something. Two tables, A & B have foreign key relations to each other. A 3rd table C, inherits from A. A stored procedure updates a row in C, adds a row each in B & C. I get an integrity violation. All the foreign keys are deferrable, and the stored procedure is called from within a transaction with constraints deferred. (And the foreign keys do refer to...
17
12828
by: Dr NoName | last post by:
Help! I have a table that multiple processes must be able to write to concurrently. However, it for some reason gets locked in exclusive mode. I narrowed it down to one SQL statement + some weirdness with foreign keys. To debug this, I opened two psql sessions and typed in the sql statements manually. Here is the situation: CREATE TABLE take2
4
15836
by: maricel | last post by:
I have the following base table structure - DDL: CREATE TABLE "ADMINISTRATOR"."T1" ( "C1" INTEGER NOT NULL ) IN "TEST_TS" ; ALTER TABLE "ADMINISTRATOR"."T1" ADD PRIMARY KEY
5
3110
by: G .Net | last post by:
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
8
6525
by: markjerz | last post by:
Hi, I basically have two tables with the same structure. One is an archive of the other (backup). I want to essentially insert the data in to the other. I use: INSERT INTO table ( column, column .... ) SELECT * FROM table2
3
2325
by: JHNielson | last post by:
I am not new to Access, but am new to the level of complexity I am now having to get into, so this question may be easy, but I don't even know what to look for to see if it has been posted here before: I have one table called "Constraints" and one table called "Input" Constraints has two columns: Field and Max. Field a list of records with the column names from Input. Max is a constraint value in the second column that the records...
5
6851
by: yeoj13 | last post by:
Hello, I have a db2load script I'm using to populate a large table. Ideally, my target table is required to have "Not Null" constraints on a number of different columns. I've noticed a huge performance hit when I load the target table with "Not Null" constraints as compared to loading a target table without the constraints.
0
8894
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8753
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9411
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9188
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
9122
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8113
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6704
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
3230
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
3
2159
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.