【发布时间】:2020-03-24 08:39:32
【问题描述】:
我这里有这段代码:
Sub Example()
Dim Conn As New Connection
Conn.ConnectionString = "Server=localhost;Port=3306;Database=testing;Uid=root;Pwd=test;"
Conn.Open
Dim rs As New Recordset
Dim sql As String
sql = "Select productcode from labels" 'put spec of desired table here
rs.Open sql, Conn
If Not rs.EOF Then
Range("a1").CopyFromRecordset rs
End If
rs.Close
Set rs = Nothing
Conn.Close
Set Conn = Nothing
End Sub
并得到这个错误代码:
run-time error -2147467259 (80004005)
我该如何解决这个问题?我想做的是:
在不使用插件的情况下将数据从 MYSQL 导出到 excel。
【问题讨论】:
-
欢迎来到 SO。完整的错误信息是什么?它是否停在
Conn.Open线?能否请您确认一下数据库、Uid 和 Pwd 是否有效? -
嗨@JustynaMK不幸的是它没有突出任何东西
-
感谢您的更新 - 我没有 MySQL,但希望我发布的答案将引导您朝着正确的方向前进。