I'm trying to connect a visualbasic .net app to a Mysql database but I'm getting the above error. I'm targeting .net framework 4.6 and I have installed Connector/NET 8.1.0 and even tried adding refferences to Mysql.Data.Dll using 5.0.0 Alpha but none is working.
The line giving errors is
Dim MysqlConn As MySqlConnection
If I change the line to
Dim MysqlConn As New MySqlConnection()
and make the connection as follows
Dim Server As String = "localhost"
Dim DbUName As String = "root"
Dim DbUPass As String = ""
Dim DbName As String = "cypos"
I get a new error An unhandled exception of type 'System.ArgumentException' occurred in System.Data.dll
on this line
MysqlConn.ConnectionString = "server='" & Server & "';user='" & DbUName & "';password='" & DbUPass & "';database='" & DbName & "'; SSL Mode=None"
I have also tried adding mysql.data.dll from version mysqlconnector version 1.0.0 beta but the error persists. What can I do to solve the issue?
Easiest way would be to install the nuget packet
Or download https://dev.mysql.com/downloads/connector/net/
and use
Dim conn As New MySql.Data.MySqlClient.MySqlConnection
Dim myConnectionString As String
myConnectionString = "server=127.0.0.1;" _
& "uid=root;" _
& "pwd=12345;" _
& "database=test"
Try
conn.ConnectionString = myConnectionString
conn.Open()
Catch ex As MySql.Data.MySqlClient.MySqlException
MessageBox.Show(ex.Message)
Finally
conn.Close()
End Try