如何W10通用的应用程序与MySQL数据库连接 [英] How to connect W10 Universal App with MySQL database

查看:787
本文介绍了如何W10通用的应用程序与MySQL数据库连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在写我的第一个Windows 10通用应用程序上MySql数据库进行操作。我使用的代码与本指南(这是针对Windows 8 Store应用程序):



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



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




类型的'System.NotImplementedException例外发生在> MySql.Data.RT.dll但在用户代码中没有处理



更多信息:本WinRT的版本不支持SSL




 公共类DBconnector 
{
静态字符串服务器=127.0.0.1;
静态字符串数据库=hurtownia;
静态字符串用户=根;
静态字符串PSWD =根;

公共静态布尔登录(字符串email,字符串密码)
{
字符串的connectionString =服务器=+服务器+;数据库=+数据库+; UID = +用户+;密码=+ PSWD +;;
使用(连接的MySqlConnection =新的MySqlConnection(的connectionString))
{
connection.Open();
的MySqlCommand checkLogin =新的MySqlCommand(选择password_hash,从用户那里电子邮件= \ password_salt+电子邮件+\连接);使用
(MySqlDataReader将读卡器= checkLogin.ExecuteReader())
{
reader.Read();
字符串哈希= reader.GetString(password_hash);
串盐= reader.GetString(password_salt);

布尔结果= passwordGenerator.compare(密码哈希,盐);

如果(结果)
返回真;
,否则
返回FALSE;
}
}
}
}



所以,我的问题是如何解决这个问题并正确连接到MySQL数据库在Windows 10通用应用程序


解决方案

添加。SslMode =无到连接字符串。


I'm writing my first Windows 10 Universal App that operates on MySql database. I used code from this guide (It's for Windows 8 store apps):

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

But when I try to open connection with my database I get error:

An exception of type 'System.NotImplementedException' occurred in >MySql.Data.RT.dll but was not handled in user code

Additional information: SSL not supported in this WinRT release.

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;
            }
        }
    }
}

So, my question is how to fix that and correctly connect to MySql database in Windows 10 Universal App.

解决方案

Add ";SslMode=None" to your connection string

这篇关于如何W10通用的应用程序与MySQL数据库连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆