Mysql – Connect thesql database using odbc in vbnet

MySQLnetodbcvb.net

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

Best Answer

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/