.net开发中遇到的问题汇总

来源:互联网 发布:mysql拖动排序设计 编辑:程序博客网 时间:2024/05/21 09:50

  • 一 C 相关
  • 二 MySQL相关
    • insert 中文出现乱码

一. C# 相关





二. MySQL相关

1. insert 中文出现乱码

这是因为在数据库连接串中没有指明编码格式导致的

//要指明编码格式  Charset=utf8 string constr = "server=localhost;User Id=root;password=;Database=test;Charset=utf8";  MySqlConnection mycon = new MySqlConnection(constr); mycon.Open();  MySqlCommand mycmd = new MySqlCommand("insert into buyer(name,password) values('小王','dikd3939')", mycon); if (mycmd.ExecuteNonQuery() > 0) {  Console.WriteLine("数据插入成功!");}  Console.ReadLine();  mycon.Close();