ForeignKey Strange behavior

G

Guest

Hi,

I have a parent table associated to a child table in a dataset. I have created a foreignkey relation that has Update and Delete set to cascade. I use two datagrid one for the parent table and one for the child table. I also created two dataadapter, generated by VB.NET, and they do return the @@IDENTITY information

The problem is this, when I call the dataadapter.update method for the child table, after I have called the update method for the parent table, I get a foreignkey constraint error that value (1) must be in the parent table. If I look in the database (SQL), the parent table have the new row in there and the child table contains the first row of the rows that were supposed to be inserted

Why does the first child row get the right primarykey from the parent table and the others don't

Here is some more information..

The dataset is a typed dataset, the constraints have been created with the visual tools. I use a seed and step of -1 for the dataset's primarykeys. I also went through the forums and looked at the information that was available on the subject. I was unable to find where I did something wrong from the examples I saw in the forums

Any help will be greatly appreciated, thanks

Mik

By the way I keep getting a page stating that Microsoft's site cannot service my request when I try to send this message.
 
G

Guest

I found the problem, the INSERT Query for the child table was was reselecting a row to return after the insert. Since there is no identity column and just a foreignkey in that table it was returning the first row of the table. That's what was causing the foreignkey error in the dataset.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top