开发者

Problem with insert Thai Language data to SQL Server 2008 field datatype text and show?

开发者 https://www.devze.com 2022-12-26 07:40 出处:网络
I created MVC ASP.Net Web application and triedinsert Thai language data to SQL Server 2008 database to field with data type text and then database store ?????? which is incorrect. For Html Page I use

I created MVC ASP.Net Web application and tried insert Thai language data to SQL Server 2008 database to field with data type text and then database store ?????? which is incorrect. For Html Page I user charset utf-8

However I tried to Encode string before insert data to database and change database field coll开发者_Go百科ation. These do not solve problem.

I'm looking forward to your reply.

Thanks,

embarus


Try using the NVARCHAR(MAX) datatype. This may solve the problem. What error are you getting?


SQL Server cannot natively store UTF-8. If you want to store UTF-8 data you have a few choices:

  1. Store it in Unicode (nvarchar) and convert it to UTF-8 on the client. It should be noted that the SQL Server driver will already convert most strings to Unicode. The obvious downside is that it eats up twice the space. However, space is cheap and this is by far the simplest solution and the least headache.
  2. Store it in binary and convert it to UTF-8 on the client (which pretty much eliminates any sorting done on the server and all your searches will be culture and case agnostic)
  3. Create a CLR user defined type in SQL Server to store UTF-8 values. Microsoft provides a sample that comes with SQL Server to do just this. You can download the samples from CodePlex from here. You can also find more information on the sample in this article in the Books Online. The downside is that you have to have the CLR enabled in SQL Server and I'm not sure how well it will perform.


You have to change you COLLATE by this code : ALTER DATABASE [DatabaseName] COLLATE Thai_CI_AS

0

精彩评论

暂无评论...
验证码 换一张
取 消