0

Context:

I have a (legacy) ASP.NET app using a class lib which's data access is calling SPs using ad dal.dbml and its generated code.

I am using VS 2015 Enterprise update 1, have locally installed Microsoft SQL Server 2014 - 12.0.4213.0 (X64) (Build 10586) and SSMS 2014.

Question

When running the Web application the app inserts rows to a table which I recently implemented an insert trigger. How can I debug the actual trigger execution "triggered" by the Web application? Note: I do know how to interactively debug SPs in SSMS. Now that is not I want, because It is nearly impossible to reproduce and parametrize what the web app does. So I would like to debug via the Web App.

Is this possible at all? (Seems to be a pretty usual need, though I unserstand it requires very complex debugging infrastructure and services)

6
  • 1
    What do you mean by (legacy) ASP.NET? ASP.NET is not something that is generally considered "legacy", as opposed to Classic ASP. Commented Apr 14, 2016 at 16:21
  • I don't think there is way to step through trigger code like that. Perhaps we can help you with your trigger if you post it. Commented Apr 14, 2016 at 16:25
  • @Tim: I meant the application is legacy. Mainly its data access layer is using legacy VS code generators. The all execution environment is the latest, including IIS Expess v? on Windows 10 and VS 2015 and SQL Server 2014. Commented Apr 14, 2016 at 16:28
  • @SeanLange: Many thanks, that is the last backup plan. The trigger calls some table valused udfs and the schema is pretty complex. The real help would be to see interactively which variable / select is empty... Commented Apr 14, 2016 at 16:33
  • Sounds to me like your trigger is entirely too complicated. Triggers should not have complex logic in them. Commented Apr 14, 2016 at 17:03

1 Answer 1

2

What you do is you run Profiler to get the typical values being sent when the error occurs.

Then the easiest way I know of to troubleshoot something like this is to take the trigger code out of the trigger and put it in a script using #inserted (and/or #deleted if need be) instead of the pseudotables accessed by the trigger.

The insert the data the stored proc would insert into the table into the #inserted table. Then you can take the trigger step by step and even look at the results of a select that is used in an insert.

The most common error I have found in triggers is that they are set up to handle only one record in inserted rather than multiple records. SO if you find that what your proc would put in for the values you get is one record, that may be the issue. Or you may be missing a required field. IN that case you may need adjust the proc to put in the value or assign a default.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for the answer. (I handle multiple rows in inserted correctly.) Actually there is no explicit error, instead an UPDATE FROM statement seems to be not doing its job probable because the SELECT part produces no row, that what I don't understand why...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.