1
votes

I'm trying to use this statement

Imports MySql.Data.MySqlClient

in VB.NET to get the objects to work with a MySQL database.

I get a build error because the MySQL package doesn't exist. However, I tried a couple different things to try to get it installed.

  1. I followed the instructions on the Oracle/MySQL site to install the .NET connector: https://dev.mysql.com/doc/connector-net/en/connector-net-installation-windows.html However, the installer only has a (x86) version and MySQL is 64-bit, so the installer puts the connector under the Program Files (x86) and not with the other MySQL files. When I go to the References in Visual Studio, there is no MySQL option. I don't think it can find things in the (x86) folders.

  2. I followed the step by step example here: https://dev.mysql.com/doc/connector-net/en/connector-net-installation-windows.html. I downloaded the zip and unzipped it, then went to Add Reference -> Browse and selected MySQL.Data. But then when I go to build the program, I get a build error and again the Reference doesn't exist.

What am I doing wrong? Or is there some other way to install the connector for 64 bit newer versions of MySQL?

2
add the reference for the file. solution explorer -> right click references -> add -> browse -> c:\program files x86\mysql\connector.net.version\assemblies\ pick your version. -> add mysql.data.dll - Chillzy
I think this is the same as my #2 above. Anyway, I opened a new project and tried it exactly as you said, and apparently it added the reference. But still the Imports line fails. This isn't working. - Michael T
Also I attempted to install MySQL for Visual Studio 1.2.7 and 2.0.5 and in both cases the install rolls back and then I get an error message that it ended prematurely due to an error. - Michael T
you should look at the log to see why your aren't able to install it. - Chillzy
I don't know where to see the log. - Michael T

2 Answers

0
votes

You can install MySQL.Data with Nuget if you use Visual Studio: Main Menu => Project => Manage Nuget Packages

This way you get the right version for the different .NET Frameworks automatically.

0
votes

Ok after more than a day and pulling out all my hair I finally hit on the right combination of things to do to fix this. I want to list my steps out for anyone in the future with a similar issue.

Note: It seems that Visual Studio Community 2017 DOES NOT work with MySQL. The key here is you have to install VS Community 2015,

  1. Fully uninstall VS Community 2017
  2. Install VS Community 2015
  3. Use Nuget to install MySQL.Data 6.10.5
  4. Use Nuget to "Update" MySQL.Data to 6.9.10 (several sources said 6.10 doesn't work so I did this, but I did not try 6.10.
  5. Install MYSQL for Visual Studio 1.2.7 (this is the missing piece; this will not install if you have VS Community 2017).

Voila - after these steps I am able to use VB.NET code to write rows into my MySQL database!