D
drops
I have a problem with an incorrect ID thats returned from the second
insert.
1) There is a table in SQL Server 2005 with an ID colum that is marked
primary key and identity to autoincrement.
2) I fill a dataset with a dataadapter from this table
3) I delete a record. dataset.update. Fine.
4) I insert a record. dataset.update. Fine.
5) I delete the record I just inserted. Dataset.update. Fine.
6) I insert the same record again. dataset.update. ERROR
Now the ID field in the dataset has the ID number from the insert in
step 4, but when I check the table in SQL Server there is a higher
number there.
My problem is that I have a second table which has a foreign key
constraint on the id of the first table. And therefore I cannot insert
into the second table. Either I take the ID from the dataset, then it
gets inconsistent in the database. Or I take the ID from the database
with a select after the update, but then the constraint of my dataset
complains.
Please help.
kind regards
Oliver Drobnik
insert.
1) There is a table in SQL Server 2005 with an ID colum that is marked
primary key and identity to autoincrement.
2) I fill a dataset with a dataadapter from this table
3) I delete a record. dataset.update. Fine.
4) I insert a record. dataset.update. Fine.
5) I delete the record I just inserted. Dataset.update. Fine.
6) I insert the same record again. dataset.update. ERROR
Now the ID field in the dataset has the ID number from the insert in
step 4, but when I check the table in SQL Server there is a higher
number there.
My problem is that I have a second table which has a foreign key
constraint on the id of the first table. And therefore I cannot insert
into the second table. Either I take the ID from the dataset, then it
gets inconsistent in the database. Or I take the ID from the database
with a select after the update, but then the constraint of my dataset
complains.
Please help.
kind regards
Oliver Drobnik