[英]mysql asp.net c# unicode
I'm crazy about getting the content from mysql db and display it in vietnamese but always get strange code. 我为从mysql db获取内容并将其显示为越南语而疯狂,但是总是得到奇怪的代码。
if (!IsPostBack)
{
string myConnectionString =
"Database=abc;Data Source=x.x.x.;User Id=abc;Password=abc;charset=utf8";
MySqlConnection myConnection = new MySqlConnection(myConnectionString);
MySqlCommand myCommand = new MySqlCommand(
"SELECT location_name FROM idv_province", myConnection);
MySqlDataAdapter myAdapter = new MySqlDataAdapter(myCommand);
DataSet myDataSet = new DataSet();
myAdapter.Fill(myDataSet, "idv_province");
foreach (DataRow row in myDataSet.Tables[0].Rows)
{
lblProvince.Text += row["location_name"].ToString() + "<br/>";
}
}
my page already has 我的页面已经有
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
it's been driving me crazy for a whole day. 整整一天让我发疯。 please help me, thanks alot.
请帮助我,非常感谢。
Just adding the meta tag for UTF-8 does not necessarily "convert" your ASPX page to UTF-8. 仅添加UTF-8的meta标签并不一定会将您的ASPX页面“转换”为UTF-8。
You also have to save the ASPX file in Visual Studio as UTF-8. 您还必须将ASPX文件在Visual Studio中另存为UTF-8。 See
File
> Advanced Save Options...
. 请参阅
File
> Advanced Save Options...
In addition, if you haven't read it, I would recommend reading Joel's introduction to Unicode . 另外,如果您还没有阅读过,我建议您阅读Joel的Unicode简介 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.