Search code examples
c#asp.netvisual-studiosqlconnectionsqltransaction

Is it possible to debug visual studio to view SqlConnection transactions


I'm currently getting an error message in my asp.net application as an SQLCommand transaction is being committed, and I can't see how it is happening. The error message states:

Cannot insert the value NULL into column 'SectorID', table 'EventHistory'; column does not allow nulls.

The error itself makes absolute sense - I shouldn't be able to add a row with a null SectorID into that table. My problem is that I can't find anywhere in that section of code that it even tries to insert into that table.

So my question - is it possible to debug this in visual studio to allow me to see all transactions that are away to be committed? I think seeing the offending row might help me pinpoint where this row is being added. I added an item in the watch window for cmd.Transaction as that looked as likely as anything but I couldn't find anything in the list of options so I'm not even sure if it's something that can be viewed when debugging.

Thanks


Solution

  • You can run a trace using the tool SQL Server Profiler. That should tell you exactly what query is being ran against the database which is raising that exception.