C# 如何将W10 Universal App与MySQL数据库连接
我正在编写我的第一个在MySql数据库上运行的Windows 10通用应用程序。我使用了本指南中的代码(适用于Windows 8应用商店应用程序): 但是,当我尝试打开与数据库的连接时,出现错误: 在>MySql.Data.RT.dll中发生类型为“System.NotImplementedException”的异常,但未在用户代码中处理 其他信息:此WinRT版本不支持SSLC# 如何将W10 Universal App与MySQL数据库连接,c#,mysql,win-universal-app,C#,Mysql,Win Universal App,我正在编写我的第一个在MySql数据库上运行的Windows 10通用应用程序。我使用了本指南中的代码(适用于Windows 8应用商店应用程序): 但是,当我尝试打开与数据库的连接时,出现错误: 在>MySql.Data.RT.dll中发生类型为“System.NotImplementedException”的异常,但未在用户代码中处理 其他信息:此WinRT版本不支持SSL 因此,我的问题是如何修复该问题,并在Windows 10 Universal App中正确连接到MySql数据库。我
因此,我的问题是如何修复该问题,并在Windows 10 Universal App中正确连接到MySql数据库。我担心MySql WinRT连接器不支持SSL连接。您必须禁用MySql服务器的SSL连接 Connector/Net RT不支持SSL连接或Windows 认证。此外,当前不支持SHA256 顺便说一句,从mysql检索数据的另一种方法是托管REST服务:
App->Rest Service->MySQL将“SslMode=None”添加到您的连接字符串中您检查过这个吗?我在MySQL Workbench中禁用了SSL:我还在我的.ini文件中添加了行跳过SSL,但我仍然存在此错误。考虑到他们的二进制发行版不支持SSL/TLS,他们竟然将SSL设为默认模式,这着实让我吃惊。您必须从源代码构建才能获得SSL/TLS支持。
public class DBconnector
{
static string server = "127.0.0.1";
static string database = "hurtownia";
static string user = "root";
static string pswd = "root";
public static bool login(string email, string password)
{
string connectionString = "Server = " + server + ";database = " + database + ";uid = " + user + ";password = " + pswd + ";";
using (MySqlConnection connection = new MySqlConnection(connectionString))
{
connection.Open();
MySqlCommand checkLogin = new MySqlCommand("select password_hash, password_salt from users where email = \""+email+"\"",connection);
using (MySqlDataReader reader = checkLogin.ExecuteReader())
{
reader.Read();
string hash = reader.GetString("password_hash");
string salt = reader.GetString("password_salt");
bool result = passwordGenerator.compare(password, hash, salt);
if (result)
return true;
else
return false;
}
}
}
}