2

I am trying to save XML content with encoding="ISO-8859-1" standalone="yes" into a SQL Server 2008 XML column. I am doing this using Entity Framework.

However doing this throws the following error

XML parsing: line 1, character 60, unable to switch the encoding

However when I try to save XML content with encoding UTF-16, it is saved without any error.

Does anyone have any inputs regarding this?

1 Answer 1

2

The encoding width must match the datatype width

So don't send:

  • UTF-8 and nvarchar/xml
  • UTF-16 and varchar

Also see Trying to store XML content into SQL Server 2005 fails (encoding problem) whcih links to http://social.msdn.microsoft.com/forums/en-US/sqlxml/thread/d40ef582-4ffe-4f4b-b6b8-03c6c0ba1a32/

Sign up to request clarification or add additional context in comments.

2 Comments

The datatype of the column in SQL Server 2008 is xml and that of property of corresponding class generated by Entity Framework is string. Also I am sending data with encoding ISO-8859-1.
@surajnaik: xml is effectively nvarchar in this case. You have to change encoding.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.