Chander Dhall's Blog

Sponsors

Tags

DataServiceRequestException was unhandled by user code. An error occurred while processing this request.

Make sure you please read the previous blog post on StorageException otherwise this would not make sense. Once we change the code in the constuctor and forget to change the table name this exception would occur. This exception occurs usually when

1. you do not have the table name which you are requesting. This could occur if you try to delete something and try to access it concurrently from some other thread. Or if you do not have the table with the same name in your storage.

2. You may just have the name there in the form of 'Emailaddress' and you are accessing it with a similar name which is CamelCased for example, 'EmailAddress'. 

DataServiceRequestException was unhandled by user code
 An error occurred while processing this request.

 If you follow the post from the previous post, this exception occurs at a different place. Even though the solution is same, the exception is different and hence somewhat misleading. The exception occurs at the save changes line and the user would normally think that the AddObject function ran well.

    public void AddEmailAddress(EmailAddressEntity emailAddressTobeAdded)
        {

            AddObject("EmailAddress", emailAddressTobeAdded);
            SaveChanges();

        }

 However, avoid the naming of the EmailAddress in the AddObject method as CamelCasing.  So changing it to "emailaddress" or "Emailaddress" fixes it. Again, it could be some other factors owing to which this exception might occur.At the time of writing this post, I had seen difference in the 32-bit environment and 64-bit environment so please cross check this. Feel free to email me the code and i shall be happy to help.

Comments

Prajakta said:

here is the code which is throwing the exception

public void Insert(ContactDataModel newItem)

       {

           _ServiceContext.AddObject(ContactDataServiceContext.ContactTableName, newItem);

           _ServiceContext.SaveChanges();

       }

# February 3, 2012 1:00 AM

chanderdhall said:

can you please let me know what does the string ContactTableName look like? For example, it might be "EmailAddress" and if you change that to "emailaddress" or "EmailAddress" it should work. However, this was a problem in the earlier versions and this might have been fixed by now.

# February 3, 2012 8:32 AM
Leave a Comment

(required) 

(required) 

(optional)

(required)