M
Massimo
Hi to all, I'm developing a test application with Visual Studio 2005 Beta 2
and the 2.0 framework (along as SQL Server 2005 June CTP), and I'd like to
know if they introduce some improvements in order to solve an old problem:
how to deal with inserting values from a DataSet into two related tables
when one of them has an auto-generated ID column.
Let's say I have these two tables in the DB, Table1 and Table2, and Table1
has an "ID" column which is configured as an auto-generating identity;
Table2 also has an ID column, which references Table1.ID in a foreign key
relation.
Now, I'm loading these two tables in a typed DataSet, which, being typed,
knows the structure of the tables and the relation between them; I put a new
row into Table1, and then another one in Table2 referencing the new
Table1.ID.
The question is: how do I put those new data into the DB, since I can't
specify the value of the column in the master table?
I know there are some workarounds for this problem (like retrieving the new
auto-generated ID and storing it in the DataSet, or using stored procedures
to update the tables, or using placeholder values in the DataSet before
submitting the changes, or using GUIDS), but I'd like to know if ADO.NET 2.0
solves this problem in a more elegant way than 1.0 and 1.1 did; the new
framework has so many improvements... this one would be quite helpful.
Thanks for any answer.
Massimo
and the 2.0 framework (along as SQL Server 2005 June CTP), and I'd like to
know if they introduce some improvements in order to solve an old problem:
how to deal with inserting values from a DataSet into two related tables
when one of them has an auto-generated ID column.
Let's say I have these two tables in the DB, Table1 and Table2, and Table1
has an "ID" column which is configured as an auto-generating identity;
Table2 also has an ID column, which references Table1.ID in a foreign key
relation.
Now, I'm loading these two tables in a typed DataSet, which, being typed,
knows the structure of the tables and the relation between them; I put a new
row into Table1, and then another one in Table2 referencing the new
Table1.ID.
The question is: how do I put those new data into the DB, since I can't
specify the value of the column in the master table?
I know there are some workarounds for this problem (like retrieving the new
auto-generated ID and storing it in the DataSet, or using stored procedures
to update the tables, or using placeholder values in the DataSet before
submitting the changes, or using GUIDS), but I'd like to know if ADO.NET 2.0
solves this problem in a more elegant way than 1.0 and 1.1 did; the new
framework has so many improvements... this one would be quite helpful.
Thanks for any answer.
Massimo