29

What does this mean: Next add reference to: MySql.Data

actually I have downloaded mysql connector/net. by following these instructions:

First, you need to install the mysql connector/net, it is located at: http://dev.mysql.com/downloads/connector/net/1.0.html

Next create a new project

Next add reference to: MySql.Data

Next add "using MySql.Data.MySqlClient;" but im not able to install the connector.

website:http://bitdaddys.com/MySQL-ConnectorNet.html

kiltek
  • 3,183
  • 6
  • 47
  • 70
srinivas
  • 1,391
  • 3
  • 13
  • 16
  • When you say that you are not able to install the connector, what do you mean? Do you get a specific error message? Does the option not appear? – Robert Columbia Feb 10 '18 at 04:23

5 Answers5

54

"Add a reference to MySql.Data.dll" means you need to add a library reference to the downloaded connector. The IDE will link the database connection library with your application when it compiles.

Step-by-Step Example

I downloaded the binary (no installer) zip package from the MySQL web site, extracted onto the desktop, and did the following:

  1. Create a new project in Visual Studio
  2. In the Solution Explorer, under the project name, locate References and right-click on it. Select "Add Reference".
  3. In the "Add Reference" dialog, switch to the "Browse" tab and browse to the folder containing the downloaded connector. Navigate to the "bin" folder, and select the "MySql.Data.dll" file. Click OK.
  4. At the top of your code, add using MySql.Data.MySqlClient;. If you've added the reference correctly, IntelliSense should offer to complete this for you.
Rob
  • 47,999
  • 5
  • 74
  • 91
20

In Visual Studio you can use nuget to download the latest version. Just right click on the project and click 'Manage NuGet Packages' then search online for MySql.Data and install.

Lyon
  • 546
  • 6
  • 16
  • I wouldn't say that using NuGet for this case is such a good option : http://stackoverflow.com/a/32294291/3402095 – Whirlwind May 18 '17 at 10:24
13

When you download the connector/NET choose Select Platform = .NET & Mono (not windows!)

user733584
  • 149
  • 1
  • 2
  • True, you need to download the .Net & Mono version. I took me several google search to understand why I can't find the dll file. – Iso May 12 '11 at 03:51
1

As mysql official documentation:

Starting with version 6.7, Connector/Net will no longer include the MySQL for Visual Studio integration. That functionality is now available in a separate product called MySQL for Visual Studio available using the MySQL Installer for Windows (see http://dev.mysql.com/tech-resources/articles/mysql-installer-for-windows.html).

Online Documentation:

MySQL Connector/Net Installation Instructions

0

This is an older question, but I found it yesterday while struggling with getting the MySQL Connector reference working properly on examples I'd found on the web. I'm working with VS 2010 on Win7 64 bit but have to work with .NET 3.5.

As others have stated, you need to download the .Net & Mono versions (I don't know why this is true, but it's what I've found works). The link to the connectors is given above in the earlier answers.

  • Extract the connectors somewhere convenient.
  • Open the project in Visual Studio, then on the menu bar navigate to Solution Explorer (View > Solution Explorer), and choose Properties (first box on the far left of the toolbar. The Solution Explorer shows up in the top right pane for me, but YMMV).
  • In Properties, select References & locate the instance for mysql.data. It's likely to have a yellow bang on it (Yellow triangle with exclamation point in it). Remove it.
  • Then on the menu bar, navigate to Project > Add Reference... > Browse > point to where you downloaded the connectors. I have only been able to get the V2 version to work, but that may be a factor of my platform, not sure.
  • Clean & build your application. You should now be able to use the MySQL connectors to talk to your database.
  • You can also now downgrade your .NET instance if you need to (we're constrained to .NET 3.5, but mysql.data.dll wants 4.0 at the time of my writing this). On the menu bar, navigate to the properties of your project (Project > Properties). Choose the Application tab > Target framework > Choose which .NET framework you want to use. You have to build the application at least once before you can change the .NET framework. Once you built once the connector will no longer complain about the lower version of .NET.
delliottg
  • 3,950
  • 3
  • 38
  • 52