Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

CLR Trigger Rollback

44 views
Skip to first unread message

David R

unread,
Dec 6, 2005, 10:15:02 AM12/6/05
to
How can I setup a CLR trigger to rollback the transaction that fired the
trigger if an exception occurs.
Here is waht I'm trying to do
SQL:
INSERT INTO myTable(column1, column2)
Values(1, 2)
C# Trigger:
...
try
{
//do some processing
}
catch (SqlException ex)
{
//rollback the insert statement
}
...
I have seen code like this SqlContext.GetTransaction().Rollback however this
seems to have benn written on one of the betas because the SqlContext does
not have a GetTransaction method in the final version.

Pablo Castro [MS]

unread,
Dec 8, 2005, 4:00:34 AM12/8/05
to
Try:

System.Transactions.Transaction.Current.Rollback();

That should do it for your scenario.

--
Pablo Castro
Program Manager - ADO.NET Team
Microsoft Corp.

This posting is provided "AS IS" with no warranties, and confers no rights.


"David R" <nos...@nospam.com> wrote in message
news:AFB8A82E-28A7-437B...@microsoft.com...

0 new messages