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

Inserting new rows into child when parent ID is autoincrement

I have a parent table that has one child table. The parent has a single
field (ID, AutoIncrement, Seed 0, Step -1 in the DataSet, Seed 1, step
1, in DataSource). The child is linked to this ID column in the parent.
I have the parent fields in textboxes and the child is a DataGrid. When
I add a new parent record, then go to add child records, I am getting an
exception that says, "ForeignKeyConstraint requires the child key values
(0) to exist in the parent table. Do you want to correct the value?" ..
I've tried multiple things to fix this, and it doesn't seem to work
right. The first thing I did was make sure I did a EndCurrentEdit when
entering the grid. Well, that helped.. However, the ID of the parent and
Child were both 0, and when it saved it to the datasource, the ID of the
parent changed and all the child records were lost. So, I then added
code to the entering event to endcurrentedit and then Update so that the
real ID would show up. Then I started to get that child key values error
again. So in the Entering event I added the code to set the default
value of the ID column in the child to the new parent ID. I still get
the same error. If I save the parent, navigate off that record and then
back to it, I can enter in child records all day, it works fine, even
without all the entering even code.. It's just on new records. What else
do I have to do here?

Thanks
Aaron
--
---
Aaron Smith
Remove -1- to E-Mail me. Spam Sucks.
Nov 21 '05 #1
1 2193

i have the same problem. how can i get the parent ID value to b
inserted into child rows??

--
kimic
-----------------------------------------------------------------------
kimico's Profile: http://www.msusenet.com/member.php?userid=2
View this thread: http://www.msusenet.com/t-30549

Nov 21 '05 #2

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

Similar topics

1
by: Engineerik | last post by:
I have a datagrid which displays rows from a parent datatable. I use a datarelation so the user can expand the child rows. How can I tell programatically when the user has expanded the child rows...
1
by: Glenn T. Kitchen | last post by:
Dear Group, I'm having problems retrieving the child rows of a parent row. The parent table is Users and the child table is Addresses. I used the Schema to create a DataRelation between the...
13
by: dbuchanan | last post by:
Hello, Here is the error message; ---------------------------- Exception Message: ForeignKeyConstraint Lkp_tbl040Cmpt_lkp302SensorType requires the child key values (5) to exist in the...
7
by: Susan Mackay | last post by:
I have a data table that is connected to a database table with a data adapter in the 'standard' manner. However I want to be able to remove selected rows from the data table (i.e. no longer...
11
by: c676228 | last post by:
Hi everyone, I am just wodering in asp program, if there is anybody writing store procedure for inserting data into database since there are so many parameters need to be passed into store...
3
by: Robert Johnson | last post by:
Hi all. Created a simple table in my db. 3 colums one is a Int set for autoincrement. Itentity True, seed 1, Incremement 1, null False. The other colums are simple VarChar(50) null false on the...
9
by: sitko | last post by:
Hi, I have an Order tracking spreadsheet that I need help with. I have a 2 worksheets "Open", and "Closed". I have entries on the "Open" sheet which may or may not be grouped together. I've...
1
nev
by: nev | last post by:
Good day Sirs & Madams, I know some of you will find this problem very simple. Kindly share a little knowledge to me on how to deal with this. Thank you. I have a parent-child table relation. when...
0
by: Ty | last post by:
Question: If the Division number changes in 1 table, it is suppose to automatically change in the other tables. If it don't change, what is the problem? Response: My professors response to my...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: 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
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
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
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...
0
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,...
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.