Home All Groups Group Topic Archive Search About

Output SqlParameter + SqlTransaction

Author
22 Feb 2006 8:51 PM
Nik
Hello,

I use an output parameter to update identity column in my table after
inserting new row and it works fine - identity value is read from the
database and written to approprate field in DataRow. However, if I do
the inserting inside a transaction and call the Rollback method after
that, the identity value is no longer valid and it should be reverted
to old value. Do I have to do this manually or is there a way to
automate this?

I work with Framework v1.1.

Thanks.

Nik

Author
23 Feb 2006 2:09 AM
Val Mazur (MVP)
Nik,

DataRow does not participate in a transaction and it will not be automatic.
What you could do is to call RejectChanges method for the DataRow and all
the data inside of the DataRow will be rolledback

--
Val Mazur
Microsoft MVP
http://xport.mvps.org


Show quote
"Nik" <niksa.bal***@gmail.com> wrote in message
news:1140641481.546119.116930@f14g2000cwb.googlegroups.com...
> Hello,
>
> I use an output parameter to update identity column in my table after
> inserting new row and it works fine - identity value is read from the
> database and written to approprate field in DataRow. However, if I do
> the inserting inside a transaction and call the Rollback method after
> that, the identity value is no longer valid and it should be reverted
> to old value. Do I have to do this manually or is there a way to
> automate this?
>
> I work with Framework v1.1.
>
> Thanks.
>
> Nik
>
Author
23 Feb 2006 7:45 AM
Nik
AFAIK, if I call RejectChanges on a DataRow whose state is Added (which
is the case here), it will be removed from the table. However, you told
me what I need to know - I have to revert the identity values manually
(or change my programming logic so it does not matter).

Thanks for reply.

Nik

AddThis Social Bookmark Button