0
votes

I have a mysql database on phpmyadmin, I installed the connector 6.8.3 (http://dev.mysql.com/downloads/connector/net/) I add a reference on the driver ((c:\Program Files\MySQL\MySQL Connector Net 6.8.3\Assemblies\v4.5\MySql.Data.dll) and I use this connexion string : Private _connexionParams As String = "Driver={MySQL ODBC 6.8.3 UNICODE Driver};Server=localhost;Database=GestionDuPersonnel;User=test;Password=test;" (from : http://www.connectionstrings.com/mys...ctor-odbc-5-2/).

When I start my program I get this error and I don't understand why : "ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified"

Thanks

2

2 Answers

0
votes

sample try this:

Imports System.Data.Odbc
Public Class Form1

Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
 Dim MyConString As String = "DRIVER={MySQL ODBC 6.8.3 UNICODE Driver};" +
 "SERVER=localhost;" +
 "DATABASE=test;" +
 "UID=root;" +
 "OPTION=3"
 Dim MyConnection As New OdbcConnection(MyConString)

 MyConnection.Open()
 MsgBox(MyConnection.State.ToString)
 End Sub
End Class

refer this link: http://kyokasuigetsu25.wordpress.com/2011/01/09/connecting-mysql-and-vb-net-using-odbc-driver/

0
votes

Finally I just do this thing

Imports System.Data.Odbc
Imports System.Data.Sql
Imports System.Data.SqlClient

Imports MySql.Data
Imports MySql.Data.MySqlClient


Public Class Test
    Public Sub Connexion()
    Dim connStr As String = "SERVER=localhost;DATABASE=GestionDuPersonnel;UID=test;PASSWORD=test"
    Dim connection As New MySqlConnection(connStr)
    connection.Open()
    End Sub
End Class

And use the connector .NET 6.8.3 : http://dev.mysql.com/downloads/connector/net/