我在 phpmyadmin 上有一个 mysql 数据库,我安装了连接器 6.8.3 ( http://dev.mysql.com/downloads/connector/net/ ) 我在驱动程序上添加了引用 ((c:\Program Files\MySQL\MySQL Connector Net 6.8.3\Assemblies\v4 .5\MySql.Data.dll),我使用这个连接字符串: Private _connexionParams As String = "Driver={MySQL ODBC 6.8.3 UNICODE Driver};Server=localhost;Database=GestionDuPersonnel;User=test;Password=test; “(来自:http://www.connectionstrings.com/mys...ctor-odbc-5-2/)。
当我启动程序时,出现此错误,但我不明白为什么:“错误 [IM002] [Microsoft][ODBC 驱动程序管理器] 未找到数据源名称且未指定默认驱动程序”
谢谢
最佳答案
示例尝试:
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
引用此链接:http://kyokasuigetsu25.wordpress.com/2011/01/09/connecting-mysql-and-vb-net-using-odbc-driver/
关于mysql - 在vb net中使用odbc连接mysql数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22937337/