2

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

e-on
  • 1,547
  • 8
  • 32
  • 65

1 Answers1

2

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.

John Paul
  • 827
  • 2
  • 6
  • 16
  • Ah that's a great idea. Never used profiler before - it was exactly what I needed to see all the queries. Unfortunately it shows none of the entries as having a null ID so back to the drawing board for this particular issue but you certainly answered this question! Thanks very much – e-on Sep 25 '15 at 12:38
  • Np glad I could help. – John Paul Sep 25 '15 at 13:09