我非常喜欢从 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" />
一整天都快把我逼疯了。请帮助我,非常感谢。
最佳答案
仅仅为 UTF-8 添加元标记并不一定会将您的 ASPX 页面“转换”为 UTF-8。
您还必须在 Visual Studio 中将 ASPX 文件保存为 UTF-8。请参阅 文件
> 高级保存选项...
。
此外,如果您还没有读过,我建议您阅读 Joel's introduction to Unicode .
关于asp.net - mysql asp.net c# unicode,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7646782/