2015-09-07 51 views
7

我正在編寫我的第一個在MySql數據庫上運行的Windows 10通用應用程序。我使用的代碼與本指南(這是爲Windows 8 Store應用程序):如何將W10通用應用程序與MySQL數據庫連接

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

但是當我嘗試打開我的數據庫連接,我得到錯誤:

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

所以,我的問題是如何解決這個問題,並正確連接到Windows 10通用應用程序中的MySql數據庫。

+0

你檢查過了嗎? http://stackoverflow.com/questions/22462441/connect-windows-8-app-to-mysql –

回答

16

添加「; SslMode =無「到你的連接字符串

+0

也適用於.NET Core,謝謝。 –

+0

考慮到他們的二進制發行版不支持SSL/TLS,我們真的很驚訝他們會讓SSL成爲默認模式。您必須從源代碼構建才能獲得SSL/TLS支持。 – Elkvis

0

我很害怕SSL連接不被MySql WinRT連接器支持。您必須禁用MySql服務器的SSL連接。

Chapter 8 Connector/Net Support for Windows Store

Connector/Net RT does not support SSL connections or Windows authentication. Also, SHA256 is not currectly supported.

6.3.6.4 SSL Command Options

BTW,檢索從MySQL數據的另一種替代方式是舉辦一個REST服務: 應用程序 - > REST服務 - > MySQL的

+0

我已經在MySQL Workbench中禁用了SSL:http://i.imgur.com/blyX30t.png 我也加了line skip.ssl my.ini文件中,我仍然有這個錯誤。 –

相關問題