Re: Advanced - C# SQL Trigger Question
From: Nicholas Paldino [.NET/C# MVP] (mvp_at_spam.guard.caspershouse.com)
Date: 12/01/04
- Next message: Randy: "Re: Rename a file"
- Previous message: Chakkaradeep: "Re: Executing an application inside a Service"
- In reply to: ChrisN: "Advanced - C# SQL Trigger Question"
- Next in thread: ChrisN: "Re: Advanced - C# SQL Trigger Question"
- Reply: ChrisN: "Re: Advanced - C# SQL Trigger Question"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 1 Dec 2004 13:50:05 -0500
ChrisN,
I don't think that using the print command is a good idea, since
anything can be printed anywhere.
I think that a better idea would be to have the trigger raise an error
that would cause an exception in .NET when executed, and then have the .NET
code handle the transaction management as well. This way, when the trigger
fails, the transaction fails, and you don't have to do anything.
Depending on the scope of the transactions, this might be a good job for
Enterprise Services.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mvp@spam.guard.caspershouse.com
"ChrisN" <cnewald@hotmail.com> wrote in message
news:%23OL$OQ91EHA.1452@TK2MSFTNGP11.phx.gbl...
> Hello all,
>
> I have a quick question. I'm using a C# object to commit new rows to a
> database. In the database I have an INSERT Trigger watching values come
> in. If the record to be committed fails the trigger's test, the trigger
> rolls back the INSERT command and no changes are made to the database.
>
> As far as my object is concerned, the transaction went through either way
> (no matter what the trigger did). What I need is for the object to be
> able to tell if the trigger has rolled back the new row or not. The
> trigger returns an error text using the PRINT command but I can't seem to
> get that error using the DataAdapter object (or any objects for that
> matter). I could get around this by searching for the newly created
> record after committing it but that seems like a bit of an overkill.
>
> Anyway, if anyone has a solution I'd be grateful.
>
> Cheers,
> Chris.
>
- Next message: Randy: "Re: Rename a file"
- Previous message: Chakkaradeep: "Re: Executing an application inside a Service"
- In reply to: ChrisN: "Advanced - C# SQL Trigger Question"
- Next in thread: ChrisN: "Re: Advanced - C# SQL Trigger Question"
- Reply: ChrisN: "Re: Advanced - C# SQL Trigger Question"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|