Windows -1252不支持编码名称. C#
发布时间:2020-12-14 04:15:56 所属栏目:Windows 来源:网络整理
导读:我正在使用 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
我正在使用
Windows 10 Universal App和ARM CPU为Raspberry Pi创建应用程序.编码时出现以下错误:
这是我的代码. 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 到连接字符串. 我该如何解决这个错误?
我解决了这个问题
System.Text.EncodingProvider ppp; ppp = System.Text.CodePagesEncodingProvider.Instance; Encoding.RegisterProvider(ppp); (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- windows-phone-7 – Windows Phone 7互联网快捷方式图标
- nuget – 如何打包一个面向通用Windows平台并依赖于Visual
- ViewMinder方向与Windows Phone 7芒果PhotoCamera
- windows-runtime – WinRt. UnhandledException处理程序. S
- windows – 我可以使用powershell强制执行密码套件
- 在xampp Windows 7上安装时必须加载PHP扩展“curl”
- wsdl – 如何访问WSO2 ESB中的注册表
- 这些Windows环境变量的含义是什么?HOMEDRIVE,HOMEPATH,HOM
- psql:致命错误:用户“postgres”WINDOWS的密码验证失败
- windows – DHCP客户端认为什么是“最佳”答案?
推荐文章
站长推荐
- POCO,DTO,DLL和贫血域模型
- windows-server-2008-r2 – 在Windows Server 20
- active-directory – 在Active Directory中授予权
- windows-sbs-2011 – SBS 2011“迁移后所有GC都已
- windows – 查找计算机的IP,查找LAN上所有计算机
- windows-7 – 用于查找用户自上次重启后是否已登
- 如何检查已修补已知的Windows漏洞?
- 在nest.dll 2.1.1上找不到ElasticType和ElasticP
- windows-installer – installshield和windowsin
- windows-8 – 在Win8和WP8应用程序中共享静态库
热点阅读