如何将W10 Universal App与MySQL数据库连接

Bar*_*ski 7 c# mysql win-universal-app

我正在编写我的第一个在MySql数据库上运行的Windows 10 Universal App.我使用了本指南中的代码(适用于Windows 8商店应用):

https://blogs.oracle.com/MySqlOnWindows/entry/how_to_using_connector_net

但是当我尝试打开与数据库的连接时,我收到错误:

> MySql.Data.RT.dll中出现"System.NotImplementedException"类型的异常,但未在用户代码中处理

其他信息:此WinRT版本不支持SSL.

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;
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

所以,我的问题是如何修复它并正确连接到Windows 10 Universal App中的MySql数据库.

小智 16

将"; SslMode = None"添加到连接字符串中