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" <(E-Mail Removed)> wrote in message
news:AFB8A82E-28A7-437B-8907-(E-Mail Removed)...
> 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.
|