http://weblogs.asp.net/guys/archive/2005/05/20/408142.aspx
i need to catch triger exception in msssql DB but i do not know which code is for this. How can i catch mssql triger in C#?
i want to catch this error:
Error Insert or Update: could not insert: [WebCrawler.Core.Entities.Advertisements][SQL: INSERT INTO [Advertisements] (Name, Description, DepartureDate, Url, Price, HollidayDuration, BookingDate, Cities_idCities, Areas_idAreas, Countries_开发者_StackOverflowidCountries, Agencies_idAgencies) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?); select SCOPE_IDENTITY()]
it is thrown by trigger.
Turn on "first chance exceptions" (ctrl-alt-e) and check the "thrown" box next to "Common Language Runtime Exceptions." Run your code from your IDE, and watch what exception gets caught. Take the name it presents to you, and put it into a catch block in your C# code.
Don't forget to turn off the "thrown" option of "first chance exceptions" when you are done.
精彩评论