我无法将vba连接到mysql。你能告诉我我哪里出问题了吗? 此方法引发运行时错误“ [[Microsoft] [ODBC Driver Manager]数据源名称未找到,未指定默认驱动程序” 我的操作系统是win 7 64位,而我刚从https://downloads.mysql.com/archives/c-odbc/安装了64位ODBC连接器 但仍然会发生错误。如果还需要指定密码,我也可以使用不带密码的xampp。
Sub SqlConnect()
Dim ReturnArray
Dim Conn As New ADODB.Connection
Dim mrs As New ADODB.Recordset
Dim DBPath As String
Dim sconnect As String
DBPath = ThisWorkbook.FullName
sconnect = "DRIVER={MySQL ODBC 5.2.2 Driver}; SERVER = localhost;" & _
"PORT=3306;" & _
"DATABASE= timeintimeoutdb;" & _
"UID=root;" & _
"PWD=;"
Conn.Open sconnect
sqlstring = "SELECT * FROM [students]"
mrs.Open sqlstring, Conn
ActiveSheet.Range("A2").CopyFromRecordset mrs
mrs.Close
Conn.Close
End Sub