ADO.NET Data Services SaveChanges() generates 404 Error

Posted on 2009-04-01
Last Modified: 2013-11-12
I have a section of code that is supposed to write updated entities back to the database.   However, every time I execute this, the .SaveChanges method generates a 404 error and the data is not saved.  I can't seem to find what the problem is.  Even with config.UseVerboseErrors = True set in the data service, I don't get any information beyond the 404 error.  I can't tell if it's permissions (it shouldn't be) or if there's a step that I'm missing.  

Any insights anyone can provide will be appreciated.  I think I need pointed in the right direction because there is obviously something I'm missing.  Based on the examples I've seen, this should work but it doesn't.  Thanks in advance for your input.
Public Sub SaveCapacities(ByRef colCapacities As Collection)


            ' Declare local variables / constants

            ' ---------------------------------------------------------------------

            m_dscDatabaseContext.MergeOption = System.Data.Services.Client.MergeOption.OverwriteChanges

            m_dscDatabaseContext.Timeout = 360000

            ' Create entity objects for each of the changed capacities 

            ' ---------------------------------------------------------------------

            For Each clsCapacity As DataModel.Capacity In colCapacities

                ' Search through the capacity entity set and get a reference to

                ' the entity that matches the capacity record.

                Dim entCapacity = (From capacity As dsrRemoteDatabase.tCAPSCapacity _

                                   In m_dscDatabaseContext.tCAPSCapacity _

                                   Where capacity.RESOURCE_ID = clsCapacity.Resource _

                                   And capacity.FACILITY = clsCapacity.Facility _

                                   And capacity.WORK_WEEK = clsCapacity.WorkWeek _

                                   Select capacity).Single

                ' Update the changeable properties of the entity object

                entCapacity.EQUIPMENT_HOURS = clsCapacity.EquipmentCapacity

                entCapacity.AVAILABLE_EMPS = clsCapacity.AvailablePeople

                entCapacity.HOURS_PER_EMP = clsCapacity.HoursPerWeek

                ' Mark the entity object as updated.


                ' Call SaveChanges to write the changes to the database



        Catch ex As Exception

            ' Display the exception using the standard error handler

            ' -----------------------------------------------------------------

            Dim clsErrorMessageBox As ErrorMessageBox = New ErrorMessageBox(ex)


        End Try

    End Sub

Open in new window

Question by:jmgroft
  • 3
  • 2
LVL 26

Expert Comment

by:Anurag Thakur
ID: 24039684
did you try to debug to see whats actually going wrong
what is the exception in the exception handling section?

why are you having such a large timeout value?
 m_dscDatabaseContext.Timeout = 360000

Author Comment

ID: 24040317
Yes, absolutely.

First of all, ignore the timeout.  I threw that in there as part of debugging.  I wanted something ridiculously high so that it should never be a problem.  

As for the exception...
The main exception text is simply: 'An error occurred while processing this request.'
The inner exception text is just the HTML for a standard Microsoft 404 error.  Of course, the error code is also 404.  That's true whether I have config.UseVerboseErrors set to true or not - but I have it set to True right now.  So basically, the exception gives me no information at all.  When tracing through the app, I watch it step into the entity logic and populate the properties of the entity, but after all properties are populated, there's a brief pause while it attempts to save the change.  Unfortunately, that internal logic is not visible through the trace.  It is during that process that it fails because the next line the trace shows is the exception being thrown.

So that would suggest that the problem is occurring at the dataservice level - perhaps permissions and such, but everything is wide open.  What I'm looking for are some ideas to pursue.  What are some reasons that a SaveChanges call would generate a 404 error?  The entities are already there and visible or I wouldn't have them to update.  So what are some reasons that this particular error would be generated on a save?

LVL 26

Expert Comment

by:Anurag Thakur
ID: 24040383
can you give an idea after how much time of processing the error is coming


Author Comment

ID: 24049354
Yes, it's immediate.  There's not really a noticeable delay before the error occurs.

Accepted Solution

jmgroft earned 0 total points
ID: 24210968
Ultimately, this turned out to be a security error.  The database security had changed without my knowledge.  Write access was disabled, but read access was still enabled.  Because the write operation was not successful, the 404 error was returned.  One the security was fixed, this worked like a charm.

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK ( for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA.…
Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now