MySQLConnection DBConn;
DBConn = new MySQLConnection(new MySQLConnectionString("localhost" , "admin" , "root" , "123456" , 3306).AsString);
DBConn.Open();
MySQLCommand DBComm;
DBComm = new MySQLCommand("select * from tb1" , DBConn);
MySQLDataReader DBReader = DBComm.ExecuteReaderEx();
try
{
while (DBReader.Read())
{
Console.WriteLine("Host = {0} and User = {1}", DBReader.GetString(0),DBReader.GetString(1));
//注:DBReader.GetString(0)在数据库中存的是中文,但查询出来是‘乱码’ 显示到页面是全是?
    怎么解决这问题?数据库编码格式没问题(gb2312)
别说配置web.config,试过了,不管用。
也别说编码解码,都不管用。
}
}
finally
{
DBReader.Close();
DBConn.Close();

DBConn.Close();

解决方案 »

  1.   

    Data Source=localhost;Port=3306;User ID=???;Password=????;Initial Catalog=?????;Pooling=true;Allow Zero Datetime=true;charset=gb2312
      

  2.   

    你意思是DBConn = new MySQLConnection(new MySQLConnectionString("localhost" , "admin" , "root" , "123456" , 3306).AsString); 
    改成:
    DBConn = new MySQLConnection(new MySQLConnectionString("localhost" , "admin" , "root" , "123456" , 3306,在这里加上gb2312).AsString); 你怎么知道参数顺序呢?
      

  3.   

    你意思是DBConn = new MySQLConnection(new MySQLConnectionString("localhost" , "admin" , "root" , "123456" , 3306).AsString); 
    改成:
    DBConn = new MySQLConnection(new MySQLConnectionString("localhost" , "admin" , "root" , "123456" , 3306,在这里加上gb2312).AsString); 你怎么知道参数顺序呢?
      

  4.   

    到这个MySQLConnectionString方法里修改下参数。