我为Windows 10桌面编写UWP应用程序
我尝试连接到服务器上的数据库
我的代码:
using (MySqlConnection connection = new MySqlConnection("Database= milano_app2;Data Source=IP_OF_SERVER;User Id=USERNAME;Password=;SslMode=None;"))
{
connection.Open();
MySqlCommand createCommand = new MySqlCommand("CREATE TABLE demotable(salary int,surname varchar(255))", connection);
createCommand.ExecuteNonQuery();
MySqlCommand addCommand = new MySqlCommand("INSERT INTO demotable (salary,surname) VALUES (1234,'Вейдер')", connection);
addCommand.ExecuteNonQuery();
}
我认为BD的编码有问题吗?
我怎样才能成为UTF-8?
感谢您的帮助。
答案 0 :(得分:2)
将CharSet = utf8添加到连接字符串:
"Database= milano_app2;Data Source=IP_OF_SERVER;User Id=USERNAME;Password=;SslMode=None;CharSet=utf8;"