當試圖將字符串保存到我的數據庫表格中時,它們會被保存爲問號。將日文字符寫入表格
我已經簽出了這個問題(還有更多): Why is sql server storing question mark characters instead of Japanese characters in NVarchar fields?
不幸的是,沒有任何揮起結果我。 我在開始時將Collation設置爲「SQL_Latin1_General_CP1_CI_AS」,但稍後我將其更改爲「Japanese_CI_AS」。仍然沒有變化。
我的代碼類似於這樣(對不起,不具有真正的代碼,這是對我的筆記本電腦):
string query = "INSERT INTO ArticlesTBL (ArticleTitle, ArticleContent,
ArticleType, ArticleImg, ArticleBrief, ArticleDateTime, ArticleAuthor, ArticlePublished, ArticleHomeDisplay, ArticleViews)";
query += " VALUES (@ArticleTitle, @ArticleContent, @ArticleType, @ArticleImg, @ArticleBrief, @ArticleDateTime, @ArticleAuthor, @ArticlePublished, @ArticleHomeDisplay, @ArticleViews)";
SqlCommand myCommand = new SqlCommand(query, myConnection);
myCommand.Parameters.AddWithValue("@ArticleTitle", ArticleTitleTextBox.Text);
myCommand.Parameters.AddWithValue("@ArticleContent", ArticleContentTextBox.Text);
// ... other parameters
myCommand.ExecuteNonQuery();
ArticleContent將與日文字符的字符串。
我的數據庫是在MS SQL Server 2014上創建的,我正在使用Visual Studio 2015編寫這個小應用程序。
什麼是列的數據類型? –
follow this cmd.Parameters.Add(new SqlParameter(「@ ArticleContent」,SqlDbType.NVarChar))。Value = ArticleContentTextBox.Text – dawncode
@PatrickHofman對不起。列的數據類型是VarChar。使用NVarChar可以解決這個問題嗎? – Kohnarik