1

Background:

I have developed a class library project that contains business logic classes and data access logic classes.

I am using a Microsoft SQL Server 2012 database (express) to save my data.

The business logic classes have save methods that perform validation and any necessary pre-save logic. Once the validation and pre-saving is successful, the save methods use the data access layer methods to create a transaction with a new connection to the database and uses DataAdapters update my database.

I have been using these classes in a WPF project and everything works 100% of the time.

I am now working on an ASP.NET MVC 3 project to create a web version of the same application. I am using the same class library in my ASP.NET application as I am in the WPF application.

I am using VB.NET for implementation in all of my projects.

Problem:

One of my classes is not updating the database with data that has been changed from my ASP.NET application.

I have stepped through the save logic from the UI layer all the way down through the data access layer and everything is properly set and the transaction commit does not throw any exceptions or indicate that anything went wrong BUT the information is not set in the database!

I have made sure that the rows are modified with the data, that the DataAdapter Update method is called, that the transaction commit method is called... everything looks fine and no errors are thrown. I tried other classes used by the ASP.NET application and found that their saves were being committed to the database perfectly fine (these classes use the same design for saving data as the problematic class does). I also tried calling the save method on the problematic classes from my WPF application and everything works fine (the commit actually commits the data to the database).

I am completely at a loss right now and have no idea how to fix my problem.

Please give me some ideas about how to debug this issue!

I am not going to post code because it is way too much to ask people to look at it. I am simply looking for suggestions on how to debug this and any suggestions on what to check if someone else has experienced this problem.

Frinavale
  • 3,908
  • 10
  • 44
  • 74
  • 2
    Have you tried using SQL Profiler against your database to capture the actual calls to the database? Also, are you calling stored procedures in the database and do those stored procedures have Set XACT_ABORT ON ? – George Mastros Feb 26 '14 at 16:23
  • I am using SQL Express so I don't have that option. I tried using the sp_who stored procedure but it didn't help me very much. – Frinavale Feb 26 '14 at 16:37
  • I am calling stored procedures to save my information. – Frinavale Feb 26 '14 at 16:37
  • I did not know about the Set XACT_ABORT ON and I was wondering if I can add this to my command? Is there a way to use this without using a stored procedure? – Frinavale Feb 26 '14 at 16:43
  • 1
    @Frinavale For the profiler, see http://stackoverflow.com/a/14496289/870604 – ken2k Feb 26 '14 at 16:43
  • I just tried adding Set XACT_ABORT ON to my sql command and it didn't help... – Frinavale Feb 26 '14 at 16:48
  • If you are using a stored procedure and the procedure has transactions, then you should use SET XACT_ABORT ON within the procedure. – George Mastros Feb 26 '14 at 16:57
  • 1
    I suggest you take a look at this: http://stackoverflow.com/questions/11382105/set-xact-abort-on-not-worked-in-create-procedure – George Mastros Feb 26 '14 at 17:02
  • Did you commit the transaction explicitly? Check if you have some if condition that may be returning from method before committing. – Akash Kava Feb 26 '14 at 17:34
  • Thank you guys so much! I was able to run the profiler and discovered that the commit is working fine. The error was updating the wrong row because one of the IDs wasn't selected properly. Profiler was the key to helping me figure out what was wrong! – Frinavale Feb 26 '14 at 18:00
  • @ken2k Could you please post your response as an answer so that I can mark it as the answer to this question? Thanks. – Frinavale Feb 28 '14 at 17:52

1 Answers1

0

The best thing you could do is to run a SQL Server profiler instance to see what's happening at the DB level.

As you're using a 2012 Express edition of SQL Server, see this link so you can get the SQL Server profiler anyway.

Community
  • 1
  • 1
ken2k
  • 48,145
  • 10
  • 116
  • 176