我正在使用
Windows 10 Universal App和ARM cpu为Raspberry Pi创建应用程序.编码时出现以下错误:
Additional information: ‘windows-1252’ is not a supported encoding name. For information on defining a custom encoding,see the documentation for the Encoding.RegisterProvider method.
这是我的代码.
private async void Login(string passcode) { try { MysqLConnection conn = new MysqLConnection("Server=127.0.0.1;Port=3306;Database=database;Uid=username;Pwd=password;SslMode=None;charset=utf8"); MysqLCommand cmd; conn.Open(); cmd = new MysqLCommand("Select * from users where User = '" + passcode + "'",conn); MysqLDataReader dr; dr = cmd.ExecuteReader(); int count = 0; while (dr.Read()) { count += 1; } if(count == 1) { var dialog = new MessageDialog("Logged In"); await dialog.ShowAsync(); } else { var dialog = new MessageDialog("Error"); await dialog.ShowAsync(); } } catch (Exception ex) { if (ex is MysqLException) { MysqLException exl = (MysqLException)ex; var dialog = new MessageDialog(ex.Message + Environment.NewLine + exl.Number); await dialog.ShowAsync(); } else { var dialog = new MessageDialog(ex.Message + Environment.NewLine); await dialog.ShowAsync(); } //throw; } finally { conn.Close(); } } }
dr = cmd.ExecuteReader();
在我习惯之前
conn.open();
charset=utf8
到连接字符串.
我解决了这个问题
原文链接:https://www.f2er.com/windows/364564.htmlSystem.Text.EncodingProvider ppp; ppp = System.Text.CodePagesEncodingProvider.Instance; Encoding.RegisterProvider(ppp);