How to solve “unable to switch the encoding” error when inserting XML into SQL Server

后端 未结 8 2027
醉梦人生
醉梦人生 2020-11-28 07:29

I\'m trying to insert into XML column (SQL SERVER 2008 R2), but the server\'s complaining:

System.Data.SqlClient.SqlException (0x80131904):
XML

8条回答
  •  囚心锁ツ
    2020-11-28 07:58

    A string is always UTF-16 in .NET, so as long as you stay inside your managed app you don't have to care about which encoding it is.

    The problem is more likely where you talk to the SQL server. Your question doesn't show that code so it's hard to pin point the exact error. My suggestion is you check if there's a property or attribute you can set on that code that specifies the encoding of the data sent to the server.

提交回复
热议问题