.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

Help with Error - ObjectStateManager - key already exists

Posted By:      Posted Date: December 04, 2010    Points: 0   Category :ASP.Net

I am getting this error

ERROR: Unable to Save Full Address - An object with the same key already exists in the ObjectStateManager. The existing object is in the Modified state. An object can only be added to the ObjectStateManager again if it is in the added state.

After the user clicks the update button...I fire a series of method calls to a class. Each method updates a different section of the database.

I just added one more at the end and now I have hit this error message.

Here is the code

    public bool SaveFullAddress(string cartID, string street, string city, string province, string country, string postal)
        Boolean result = false;
        using (CommerceEntities db = new CommerceEntities())
                var myAdd = (from c in db.UBOecShips
                             where c.CartID == cartID
                             select c).FirstOrDefault();
                if (myAdd == null)
                    MessageBox.Show("The address was not saved as no record has been initiated");
                    myAdd.shipStreet = street;
                    myAdd.shipCity = city;
                    myAdd.shipProv = province;
                    myAdd.shipCountry = country;

View Complete Post

More Related Resource Links

The object cannot be deleted because it was not found in the ObjectStateManager error ...

I'm trying to delete records and getting an error:   public static void Delete(int ID) { using (OLTPRewardsEntities context = new OLTPRewardsEntities()) { var productToDelete = from r in context.rewards_product where r.referral_id == ID select r; if (productToDelete != null) { context.DeleteObject(productToDelete) context.SaveChanges(); } } }  

Why is that I am not able to create login? Error:Server Prindipal 'ms\**** already exists

Hi,   When I try to cretae a login, it gives the following error: Server Prindipal 'ms\**** already exists. The login is not there in sys.server_principals table also.  

Replication : Error: subscription already exists

I am receiving an error when i try to recreate a subscription. Error: subscription already exists. I ran expired subscription clean up job but still received this error. what am i missing?

No Item Exists Error

I have a edit form that has a custom list form (call it list A) and several mutli item forms (call these list 1, list 2, list 3) on it. When I try to edit some of the items I get the following error: No item exists at http://stpi35/ResourceAllocation/Lists/Management Fee Survey/EditForm_11.aspx?ID=12&List=f3d96856-bcda-4ef1-ae4e-a0ed0ddb97bc&Source=http://stpi35/ResourceAllocation/Lists/Management Fee Survey/AllItems.aspx.  It may have been deleted or renamed by another user. None of the lists have a column that I created called ID I have noted that if my main item list (list A) has 4 items and one of the supporting lists (list 1) has only 3 items I can edit items 1, 2, & 3 on list A but item 4 causes the error to be thrown. I am guessing the Id = 4 is being somehow applied to list 1 (one of the embedded multi item forms) and since it only has 3 items it is causing the error. The multi item form for list 1 does not have a query string (I am not filter just wanting everything to show) In searching for a solution I came across this article -> http://support.microsoft.com/kb/972225/EN-US The resolution was --> Change the query string parameter from ID to CustomID. Then change the details page from QueryString(ID) to QueryString(CustomID). I can change the query string parameter on the custom list form to CustomID but where is the details page? (If t

Linked Server Mapping Error "Access to the remote server is denied because no login-mapping exists"


SQL Server 2005 SP3 32bit server
Connecting to an Oracle 10g server
Loaded OracleClient 10g

I'm able to ping the Oracle Server, and ODBC connect and able to run an open query with a single remote user id.

Issue: When I use the security context "Be made using this security context" it connects.
When I choose the "Not Be Made" WITH THE SAME USER ID & PASSWORD, I get the mapping error.

Error opening installation log file. Verify that the specified log file locaion exists and is writab


I am running windows 7 and had to reinstall because of gradual problems till finally it would not start. I am reinstalling my programs, I still use MS Money 2001 and am having problems installing it. I have had to set permissions on severial folders to acess them, but I don't know where this one is that the error message refers to. This error message is from windows installer

Could somone point me in the right direction? Money was running on windows 7 after I up graded from Vista.


Jonathan C

SSIS Database Transfer Error - "Role Exists" even though DB is being overwritten in task.



Can't get over this error, and net searches reveal other postings similiar, but no answers.

SSIS database transfer task (with overwrite) from SQL 2k source to SQL 2k5 destination fails with:


Error: The Execute method on the task returned error code 0x80131500 (ERROR : errorCode=-1073548784 description=Executing the query "CREATE ROLE [RFRSH_USER] " failed with the following error: "User, group, or role 'RFRSH_USER' already exists in the current database.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.  helpFile= helpContext=0 idofInterfaceWithError={8BDFE893-E9D8-4D23-9739-DA807BCDC2AC}). The Execute method must succeed, and indicate the result using an "out" parameter.

The error seems the same regardless if the destination DB exists or not!

Anyone have a solution?




Attempting to re-start OSearch14 gives Error 183: Cannot create a file when that file already exists


The SharePoint 2010 Health Analyzer logged the following error: "One or more services have started or stopped unexpectedly."  with detail "The following services are managed by SharePoint, but their running state does not match what SharePoint expects: OSearch14."  

Attempting to restart the service via the Windows Services gives the error:  "Windows could not start the SharePoint Server Search 14 service on Local Computer.  Error 183:  Cannot create a file when that file already exists."

A command-line approach ("net start OSearch14") run as administrator gives the same results:

The SharePoint Server Search 14 service is starting.
The SharePoint Server Search 14 service could not be started.
A system error has occurred.
System error 183 has occurred.
Cannot create a file when that file already exists.

To what file is it referring?  What is the appropriate action?

IsapiModule Error 500 Issue


I am about exhausted trying to figure out this error:

HTTP Error 500.0 - Internal Server Error

Description: The page cannot be displayed because an internal server error has occurred.

Error Code: 0x8007007b

Notification: ExecuteRequestHandler

Module: IsapiModule

Requested URL: http://localhost:80/ReportServer

Physical Path: c:\Program Files\Microsoft SQL Server\MSSQL.2\Reporting Services\ReportServer

When I enable Failed Request Tracing Rules and view the log output I am supposing that the actual problem is in the 2nd call where there are 2 backslashes before the actual filename in the specified path:


CALL_ISAPI_EXTENSION DllName="C:\Windows\Microsoft.NET\Framework\v2.0.50727\\aspnet_isapi.dll"


Handling 404 page not found with Error page



      How do i handle 404 page not found?

Inserting personal error message in ValidationSummary



I am creating a web form that requires a lot of validation. I use many of the validation control in asp.net already like RequiredFieldValidator and CompareValidator. 

My Problem: after my custom validation for the value entered return an error message, and I pressed enter key when the field is empty, my custom error message is overlapped by my ValidationSummary. 

Setting my custom error to visible = false on button click also does not seem to work as it requires for me to enter the value first.

This made me think, is there a way to insert my custom validation inside the ValidationSummary as an error message like for other validation control?

Thanks in advance

Sys.Net.WebServiceFailedException: The server method '' failed with the following error:



Let's say we have 2 time consuming functions, aaa and aaa1 inside a aspx page.

        public static string aaa(int i)
            return i.ToString();

        public static string aaa1(int i)
            return i.ToString();



        <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true">
        <span id="displayspan"></span>
        <br />
        <input type="button" value=

Jscript error: Object does not support property or method


 Hi, i have little knowledge on javascript but i need to use this code get from somewhere for a jquery to work.

I face this "Jscript runtime error: Object does not support property or method" whenever im trying to run this page.

In my experience, im get this error msg 9 out of 10 times i use javascript in my system.

Im using Microsoft Visual web developer 2008, i wonder if this is related to my problem, i not sure there is anything i need to add as reference or update anything.

But anyway, in short, i just couldn't use javascript code when using this development tool because of this sort of error.

Anyway, it happen that last time i tried use the same type of jquery code in another project and it seems to work well without an error.

But now when im try to use it again in this recent project i created, it come out with this error and i have no idea how to solve it even look through google and this forum.

It doesn't really seems like its the code problem itself although im not sure, because any javascript code just couldn't work.

So below is my code that i need to use.

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" ></script>
<script type="text/javascript" src=&quo

Type or namespace error.


A couple of days ago I started getting an unusual behavior when compiling Website projects. I have referenced class libraries added to my bin folder that are also correctely referenced in using statements in my aspx.cs code behind. When I compile, I get the 

Error 4 The type or namespace name 'CommonClassLibrary' could not be found (are you missing a using directive or an assembly reference?) C:\Dev\Fiscal_Portal\Implementation\FMS Portal Site_new\App_Code\BLL\DataTables.cs 1 7 C:\...\FMS Portal Site_new\

The type or namespace name 'CommonClassLibrary' could not be found (are you missing a using directive or an assembly reference?)

error message that would typically be received when the dll has not been added as a reference or added in a using statement.

I can eliminate the error by adding an


HTTP Error 403 - Forbidden


(VB Express website directed me to ASP.NET Web Services which in turn redirected me to this forum).

 Hopefully someone can help me here...... 

I am using VIsual Web Developer and downloaded the small business application to use as a starting point to help my wife get a website up for her small business. When I load the application, I can F5 and it runs fine but as soon as I make any modification to the app and hit F5, I get the HTTP Error 403 - Forbidden when it tries to show the website.

I notice a pop up that occurs when I run that allows me to choose the link for my app and it displays correctly (I close the webpage that has the error on it).

This seems like a pain, is there a setting I'm missing - I would think that this should "just work".

What's up?????



Webmatrix error


When i try to do anything in webmatrix it shuts down.   i get this error in the log

pplication: WebMatrix.exe
Framework Version: v4.0.30319
Description: The application requested process termination through System.Environment.FailFast(string message).
Message: Unrecoverable system error.
   at System.Environment.FailFast(System.String)
   at MS.Internal.Invariant.FailFast(System.String, System.String)

Insert Error not helpful



I am using VS2010

When I try to updated or insert a record in my User table I am getting an error that does not make sense to me and I cannot figure out what is wrong.

Also, when I try to insert a new record I get a validation error saying that the Id is required. However it is an identity field in the db so it should not be necessary to send it to the server.

Could you please shed some light?


An error has occurred.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: Microsoft.Web.UI.WebControls.EntityOperationException: An error has occurred.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. 

Stack Trace:

[EntityOperationException: An error has occurred.]
   Microsoft.Web.UI.WebControls.DomainDataSourceView.PerformCudOperation(ChangeSetEntry operation, Action`1 operationPerformingEvent, Action`1 operationPerformedEvent) +331
   Microsoft.Web.UI.WebControls.DomainDataSourceView.UpdateObject(Object oldEntity, O

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend