asp.net - mysql asp.net c# unicode

标签 asp.net mysql utf-8

我非常喜欢从 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/

相关文章:

asp.net - LINQ:如何重写查询中的 WHERE 子句?

c# - 在asp.net mvc 5中创建可编辑的cshtml View 页面

php - Mysql 连接通过第三个表关联的两个表

php - Mobiweb 短信提供商 自动 dlr 转发

asp.net - 出生日期验证

c# - 本地化 resx 文件中资源字符串的参数

MySQL Left Join Right Join union 返回不正确的数据

java - 运行 Java 工件时显示 Unicode 字符出现问题,但在 IntelliJ IDEA 中运行时一切正常

php - 比较 PHP 中的 Unicode 字符

google-chrome - 这个 INSANE 空间字符是什么??? (谷歌浏览器)