Solved

ADO.NET Data Services SaveChanges() generates 404 Error

Posted on 2009-04-01
5
940 Views
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)
 
        Try
            ' 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.
                m_dscDatabaseContext.UpdateObject(entCapacity)
 
                ' Call SaveChanges to write the changes to the database
                m_dscDatabaseContext.SaveChanges()
 
            Next
 
        Catch ex As Exception
            ' Display the exception using the standard error handler
            ' -----------------------------------------------------------------
            Dim clsErrorMessageBox As ErrorMessageBox = New ErrorMessageBox(ex)
            clsErrorMessageBox.Show()
 
        End Try
 
    End Sub

Open in new window

0
Comment
Question by:jmgroft
  • 3
  • 2
5 Comments
 
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
0
 

Author Comment

by:jmgroft
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?

0
 
LVL 26

Expert Comment

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

0
 

Author Comment

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

Accepted Solution

by:
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.
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

While working on Silverlight and WCF application, I faced one issue where fault exception occurred at WCF operation contract is not getting propagated to Silverlight client. So after searching net I came to know that it was behavior by default for s…
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…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

770 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