How can I connect to a mySQL Server from a Windows 10 IOT Universal app? The official mysql.Net connector doesn't work for WP projects. The error from nuget is: MySQL.NET 6.6.4 is not compatible with UAP,Version=v10.0 (win10-x64-aot).

How can I store data to a mysql database? Or are there any other options to store the data?

  • where is this mysql database running? Is it running on a Raspberry Pi?what OS, what version, etc. – brianlmerritt Nov 2 '15 at 19:07
  • MySQL is running in the Internet, because of the Internet of Things. :-) the MySQL Version is 5.5.43. On Raspi runs Win 10 IOT. I Need a Connection form the win 10 app to mysql – user2025830 Nov 2 '15 at 22:04

The NuGet package may not have passed testing yet for IoT.

There seems to be one way to do this.

  1. Go to https://dev.mysql.com/downloads/connector/net/ and downlaod the .NET & Mono version, no install.
  2. You may have to go through registration to get the download.
  3. Extract the contents and manually reference the RT DLL (Don't forget to set copy on build on the reference property pane, so the DLL gets copied to /bin on publish)

This DLL does not support SSL so your connection string needs sslmode=none adding to it. Possibly your server needs to be able to accept non SSL too.

private const string mySQLConn = "Server={IP};Database=IoTApps;Uid=IoTApplication;Pwd={xxxx};SslMode=None;";

To get a DB connection you can use something like...

 public MySqlConnection GetDB(string connectionString)
     MySqlConnection db = new MySqlConnection(connectionString);
     return db;

You should be able to use Dapper on the IDBConnection of MySqlConnetion too and execute normal SQL commands now to mapped objects.

Don't forget to close the db connection on dispose.

* Dapper

* Dapper single file source code if Nuget isnt playing ball again

* A nice tutorial on dapper

  • i tried this with a mysql db in the internet and with a local mysql db on my computer. but both ends in the same error: {"Authentication to host 'localhost' for user 'root' using method 'mysql_native_password' failed with message: Access denied for user 'root'@'localhost' (using password: YES)"} connestion string for local db is: "server=localhost;uid=root;database=mydb;Pwd={test};SSLMode=None" – user2025830 Nov 7 '15 at 19:03
  • 1
    OK, so it connecting :) Thats good. The best this is to try a visualiser tool, like MySQL Workbench. Test that you can connect to your server then use that connection string in C# - That should solve the problem. You possibly missing password?Or something in the connection string?? Or permissions on the DB you created, something like that. Where is the server? are you sure the login is root? If its another Linux server I dont think root is allowed to be used for non local connections. – Piotr Kula Nov 7 '15 at 19:05
  • The connection with MySQL Workbench to the server works well. Where can I see the connection string? With MySQL Workbench I created a local database for testing, but there was the same problem when I try to connect from the C# code – user2025830 Nov 9 '15 at 14:21
  • 1
    Just to try out, try and remove the SLLMode bit and see if that helps. The error message is pretty clear, Access Denied for user root@localhost make sure you dont have "'root'" as as the user but just "root" - maybe the apostrophes are the issue? – Piotr Kula Nov 9 '15 at 15:50
  • 1
    Now it works. The apostrophes makes the problems. But then I became a win-1252 encoding error but this helped for me: stackoverflow.com/questions/32471058/… – user2025830 Nov 10 '15 at 8:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.