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

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_19678579/article/details/75070777

一. 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();






猜你喜欢

转载自blog.csdn.net/qq_19678579/article/details/75070777
今日推荐