0

My ASP.NET website has a Linq-To-Sql database connected with a connection string to an SQL 2008 DB.
Locally, when using an MDF file, everything worked fine. I had a "loader" method, looping though files (only once, via admin panel), parsing them and adding to the database. They contain Unicode Hebrew text. I had done this locally. Then, my local website would print out the correct Unicode Hebrew characters to the HTML document. My whole website is in Hebrew.

With the connection string provided by my shared hosting provider, dumping the SQL DB (without data!) to an sql, executing on server & loading it up from the files, I start seeing question marks (???) instead of Hebrew characters (the website itself, which is in Hebrew shows up correctly). The SQL database has text type fields.

The more funny thing is, that it has been working for some time correctly before showing up question marks (!).

How can I make the Hebrew characters show up correctly? Thank you!

4

2 に答える 2

2

The text data type in SQL server represents:

Variable-length non-Unicode data in the code page of the server and with a maximum string length of 2^31-1 (2,147,483,647). (emphasis mine)

So, because GoDaddy has a different code page on the server than you do, the unicode chars are getting mangled. text was never meant to contain unicode.
You need to use nvarchar(max) instead.

As DJ Kraze correctly noted, prefixing your strings with N might also be necessary (I thought it might help to add the explanation). But since you are using LINQ to SQL, that's not the problem in your case (good catch @Jon Hanna, I missed that tag).

于 2012-08-15T00:19:36.520 に答える
-1

ここに役立つかもしれない良い例/説明があります

以下のように文字列の先頭にあるNの問題を解決できます。これは、「N」の使用方法の例です。

 string Status_Update = "UPDATE global_status SET  title = '" +
 Title + "', info =N'" + Info + "'  WHERE id = '" +
 Request.Form["Some_Key"] + "'";

また、nvarcharまたはunicodeを試してください

于 2012-08-15T00:21:14.657 に答える