mysql asp.net c# unicode
我很喜欢从 mysql 数据库获取内容并用越南语显示它,但总是得到奇怪的代码。
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/>";
}
}
我的页面已经
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
让我发疯了一整天了。请帮助我,非常感谢。
I'm crazy about getting the content from mysql db and display it in vietnamese but always get strange code.
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
仅添加 UTF-8 的元标记并不一定会将您的 ASPX 页面“转换”为 UTF-8。
您还必须在 Visual Studio 中将 ASPX 文件保存为 UTF-8。请参阅
文件
>高级保存选项...
。另外,如果你还没有读过,我建议你阅读Joel 的 Unicode 简介 。
Just adding the meta tag for UTF-8 does not necessarily "convert" your ASPX page to UTF-8.
You also have to save the ASPX file in Visual Studio as UTF-8. See
File
>Advanced Save Options...
.In addition, if you haven't read it, I would recommend reading Joel's introduction to Unicode.