Solved

ADO.NET Data Services SaveChanges() generates 404 Error

Posted on 2009-04-01
5
944 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
[X]
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
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

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

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…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
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…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…

717 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