Working with Project Server datasets and the web services – don’t AcceptChanges!

I thought this was one worth mentioning to a wider audience in case it catches others out.  One of our customer had written some code to update data in the timesheet using the PSI.  All seemed to be working OK, but no numbers changed.  You could even debug in Visual Studio and use the cool data visualizer to see the dataset and watch the changes – but even though the call worked and the queue showed a successful update the timesheet didn’t reflect the changes.  The right dataset was also being passed to the final web service – in this case the QueueUpdateTimesheet method of the Timesheet web service.

I then noticed that the customer had an ADO.NET “AcceptChanges” call on the dataset before the call to the web service.  This was breaking the update as the web service is expecting the dataset to have a delta holding the changes from the original read of the timehseet dataset.  The AcceptChanges is used in ADO.NET to commit changes in the dataset – but the delta then disappears.  So even though the dataset was different to that originally read from the PSI call, it didn’t have the deltas – so no changes were made to the original (different) data.  Simply removing this line got everything working again and the changes were then visible in the timesheet control of PWA!

Technorati Tags: