Joe
Joe

Reputation: 145

MySqlConnection Not Defined But Referenced (VB.NET)

I'm using Visual Studio 2013 with Mysql .Net (version 8.0.11) Connector to program a WPF application in VB.NET.

In the project references I've added the reference to MySql.Data DLL (which is located in C:\Program Files (x86)\MySQL\Connector NET 8.0\Assemblies\v4.5.2\MySql.Data.dll)

Then I've imported MySql.Data.MySqlClient in the MainWindow.xaml.vb and I've declared the MySqlConnetion as following:

Imports MySql.Data.MySqlClient

Class MainWindow
Dim connection As New 
MySqlConnection("datasource=localhost;port=3306;username=****;password=****")
Private Sub ButtonConnect_PreviewMouseDown(sender As Object, e As RoutedEventArgs) Handles ButtonConnect.PreviewMouseDown
    connection.Open()
    label.Content = "Connected"
End Sub

End Class

When I compile the project Visual Studio give me the following error:

Error   5   Type 'MySqlConnection' not defined. 

Could you help me to find the problem?

Thank you very much!

Upvotes: 0

Views: 2415

Answers (1)

Joe
Joe

Reputation: 145

SOLVED: The problem was the version of .NET FRAMEWORK.

For MYSQL NET CONNECTORS (8.x) the version of .NET Framework have to be >= 4.5.2

Upvotes: 2

Related Questions