473,406 Members | 2,439 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,406 software developers and data experts.

Dataset and identity seed columns

I have a dataset that contains two tables - Parent and Child. The key of the
Parent is called ParentID and is an identity column in SQL Server. The key of
the Child is two columns called ParentID - foreign key defined as INT to
Parent table - and ChildID that in itself is an identity column. I have used
the designer to create a relationship within the dataset for the two tables.

I have set the dataset so the ParentID column starts at -1 and increments
which works fine as in code I can make sure that the FK on the Child table is
updated correctly.

The problem is when I try to update the datasource with the dataset. What
happens is the ParentID column on the Parent table is changed by the
database, say from -1 to 101 (which is the next seeded value for that table)
but this change is not cascaded down to the Child table and this trys to add
its records where the FK column still has the value -1, hence SQL Server then
kicks off with constraint errors.

If I use the dataset Edit Relation form so the update rule etc. is changed
from Default to Cascade then the error doesn't happen as the data from the
Child table is not inserted into the database (and no errors in .Net to tell
me it didn't do the insert!)

What am I doing wrong as I can't believe it won't be allowed ?

Jul 21 '05 #1
1 1756
Stephen,

If I was you, I would ask this question in the newsgroup

Adonet
news://msnews.microsoft.com/microsof...amework.adonet

Web interface:
http://communities2.microsoft.com/co...amework.adonet

There William(Bill)Vaughn loves to answer this kind of questions. (Or better
he does not, however he investigate this problem very well)

You can as well look at this page from him
http://msdn.microsoft.com/library/de...anidcrisis.asp

I hope this helps,

Cor
Jul 21 '05 #2

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

Similar topics

2
by: William Ortenberg | last post by:
Can I change the value of a column's identity seed programmatically? If so, how? Thanks in advance.
8
by: Bruce Stockwell | last post by:
the setup: Webservice/WinClient application/SQL server. VS.Net (visual basic) winform wizard creates a simple form with load cancel cancelall and datagrid bound to a simple Dataset with one...
10
by: Eric Petruzzelli | last post by:
If I fill my dataset and there is no data. The dataset is still created with zero rows (all columns are there). When I add my first row using the script below, it takes over 2 seconds to add??? If...
17
by: Trevor Best | last post by:
I don't know if this has been reported before but it appears to be a bug with Access. If I create two tables both with an identity column then create an insert trigger on table1 that inserts a...
1
by: Stephen Ritchie | last post by:
I have a dataset that contains two tables - Parent and Child. The key of the Parent is called ParentID and is an identity column in SQL Server. The key of the Child is two columns called ParentID -...
9
by: Mr Newbie | last post by:
HI People, Thanks to all who helped me earlier on the subject of @@IDentity. However, I seem to have hit another snagette! My DataSet contains two tables from the SQL Server. lets say Master...
3
by: DavidB | last post by:
New to .net....sorry if this seems repetitive I have a dataset ordered by date (SQLDataAdapter SelectCommand uses Order By) and want to find a record by a UniqueID(Identity Column). Then I want...
1
by: matt | last post by:
hello, i have a web app that allows users to query our oracle db and produce a dataset of report data. they then have the option to serialize this data and store it in the database. later, then...
11
by: stegze | last post by:
Hi All, I have a problem with a DB2 server of my customer. It is a Debian Linux running DB2 Express-C. I have an IDENTITY field as PK in a table and I use this value as FK in another table. Two...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...
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
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...
0
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...

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.