Home > Database > Mysql Tutorial > mysql-C# Mysql datagridview控件 列标题中文乱码问题

mysql-C# Mysql datagridview控件 列标题中文乱码问题

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-06 09:44:30
Original
2002 people have browsed it

datagridviewmysql中文乱码c#

用C#从Mysql中读取数据到datagridview控件中,结果列标题中文乱码,内容没事。代码如下:
string commstr = "SELECT Patient_ID as ID,NAME as 姓名,TARGET as 患侧,DIAGNOSIS as 诊断 FROM PatientInfo";
this.data_case.DataSource = DBOperate.DBOperate.selectData(commstr, 数据库.DBConnection.SqlConnstr);
int rows = this.data_case.RowCount - 1;
for (int i = 0; i {
if (this.data_case.Rows[i].Cells[2].Value.ToString() == "L")
this.data_case.Rows[i].Cells[2].Value = "左手";
else
this.data_case.Rows[i].Cells[2].Value = "右手";
}
列标题名称本来应该是ID 姓名 患侧 诊断 的,但出现了中文乱码。我在DOS下对MySQL进行数据库查询操作,同样查询命令"SELECT Patient_ID as ID,NAME as 姓名,TARGET as 患侧,DIAGNOSIS as 诊断 FROM PatientInfo"的标题是ID 姓名 患侧 诊断,没有乱码。这是哪里出了问题,要怎么解决呢?

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template