Home All Groups Group Topic Archive Search About

Using UpdateDataSet from Enterprise Library January 2006

Author
26 Feb 2007 10:16 PM
H
I call a function with a CustomerID and it returns a dataset of two
tables (Customers, Orders).
If the ID does not exist in Customers, it returns empty tables.
I also set a relationship on CustomerID between the tables, as well as
a constraint on CustomerID.

In code, if the tables are empty, I add a new row to the Customers
table where I set the Customer details
(the primary key 'CustomerID' will be set automatically).
Then, I add a new row to the Orders table, where I set the Order
details (the primary key 'OrderID' will be set
automatically).  In that new row, I also set the foreign key column of
CustomerID to -1, so that it will
be filled with the automatically created CustomerID.

Using Enterprise Library, I call UpdateDataSet once with the main
dataset and 'Customers' table as parameters,
then I call UpdateDataSet again with the main dataset and 'Orders'
table as parameters.
(Using appropriate stored procedures)

The first UpdateDataSet call works, it creates the Customer record and
gives it a new CustomerID.
However, when I call the second UpdateDataSet, the CustomerID value is
still -1 and I get the error:

Insert statement conflicted with Column Foreign Key constraint
'FKOrders_Customers'.
The conflict occurred in database 'main', table 'Customers', column
'UDFID'.

How can I update both tables at once so that the foreign key in Orders
gets filled with the proper value?

Thanks!!!!

Author
26 Feb 2007 10:19 PM
H
the above error msg should say

Insert statement conflicted with Column Foreign Key constraint
'FKOrders_Customers'.
The conflict occurred in database 'main', table 'Customers', column
'CustomersID'.

I mistyped the column in the error msg
Author
28 Feb 2007 10:17 PM
RobinS
You posted this in another newsgroup, and somebody answered it there.

Robin S.
------------------------------------------
Show quote
"H" <halukdot***@gmail.com> wrote in message
news:1172528372.548472.6480@t69g2000cwt.googlegroups.com...
> the above error msg should say
>
> Insert statement conflicted with Column Foreign Key constraint
> 'FKOrders_Customers'.
> The conflict occurred in database 'main', table 'Customers', column
> 'CustomersID'.
>
> I mistyped the column in the error msg
>

AddThis Social Bookmark Button