I am using SQL Server 2000, VS.net 2003, C#.

In my application, when adding a row to a dataset, a primary key is
autogenerated. When I call dataadapter.Update (dataset.datatable); the
primary key is updated to match what was assigned in the database. This
works exactly as expected UNLESS there is a database trigger on the table
which is being updated. If there is a trigger on the database, the primary
key is NOT updated. If I call dataadapter.fill (dataset.datatable) again,
then I have two rows containing the same data with different primary keys.

This is a *huge* problem for me that I have not been able to overcome. Has
anyone else experienced this? Is there a solution?

Thanks,
Nate

Re: Primary Keys and DB Triggers by David

David
Mon Jul 28 11:52:08 CDT 2003


"zobie" <NOSPAM_nzobrist@holmansnv.com> wrote in message
news:%23tgYpZSVDHA.2260@TK2MSFTNGP09.phx.gbl...
> I am using SQL Server 2000, VS.net 2003, C#.
>
> In my application, when adding a row to a dataset, a primary key is
> autogenerated. When I call dataadapter.Update (dataset.datatable); the
> primary key is updated to match what was assigned in the database. This
> works exactly as expected UNLESS there is a database trigger on the table
> which is being updated. If there is a trigger on the database, the
primary
> key is NOT updated. If I call dataadapter.fill (dataset.datatable) again,
> then I have two rows containing the same data with different primary keys.
>
> This is a *huge* problem for me that I have not been able to overcome.
Has
> anyone else experienced this? Is there a solution?
>

Try using scope_identity(), instead of @@identity to return the key of the
new rows.

David



Re: Primary Keys and DB Triggers by zobie

zobie
Mon Jul 28 12:17:04 CDT 2003

Thanks for the suggestion, but scope_identity() didn't make any difference.
The row is still not updated properly.

Nate


"David Browne" <davidbaxterbrowne no potted meat@hotmail.com> wrote in
message news:#sNcWiSVDHA.1680@tk2msftngp13.phx.gbl...
>
> Try using scope_identity(), instead of @@identity to return the key of the
> new rows.
>
> David
>
>



Re: Primary Keys and DB Triggers by David

David
Mon Jul 28 12:49:46 CDT 2003


"zobie" <NOSPAM_nzobrist@holmansnv.com> wrote in message
news:eUz7RwSVDHA.1816@TK2MSFTNGP09.phx.gbl...
> Thanks for the suggestion, but scope_identity() didn't make any
difference.
> The row is still not updated properly.
>
> Nate

Post a test case to reproduce the issue.

David