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
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
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.…
In a recent question ( here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

749 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