Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


ADO.NET Data Services SaveChanges() generates 404 Error

Posted on 2009-04-01
Medium Priority
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

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Question has a verified solution.

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

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
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. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
The Relationships Diagram is a good way to get an overall view of what a database is keeping track of. It is also where relationships are defined. A relationship specifies how two tables connect to each other. As you build tables in Microsoft Ac…

579 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