gpt4 book ai didi

mysql - 尝试使用 DSN 连接到 MySql 时出错

转载 作者:行者123 更新时间:2023-11-30 01:24:05 25 4
gpt4 key购买 nike

自从使用 VB6 以来已经很长时间了,当时我没有使用 MySql 或 DSN 连接,但我正在开发一个使用这些连接的遗留应用程序。当我尝试打开连接时,我得到一个未找到数据源,并且未使用此代码指定默认驱动程序

Dim conn As ADODB.Connection
Dim cmd As ADODB.Command
Dim rs As ADODB.Recordset
Dim sql As String

Set rs = New ADODB.Recordset
Set cmd = New ADODB.Command
Set conn = New ADODB.Connection

conn.Open "DSN=AddressHealthcheck" '<- Fails on this statement

我还尝试在 conn.ConnectionString 中指定 DSN,但得到了相同的错误。

AddressHealthcheck 存在于本地系统 DSN 中,使用 MySql ODBC 5.1 驱动程序,并在测试时连接成功。

我确信(并且希望)我错过了一些明显的东西。有什么建议吗?

谢谢,凯文

最佳答案

我使用存储在 UDL 中的无 DSN ODBC。它基本上是一个包含连接字符串的文件。也许连接字符串会有用。这是一个例子:

[oledb]
; Everything after this line is an OLE DB initstring
Provider=MSDASQL.1;Persist Security Info=True;Extended Properties="Driver=MySQL ODBC 5.1 Driver;SERVER=mysqlsvr;UID=userid;PWD=password;DATABASE=mydatabase;PORT=3306;OPTION=18475";Initial Catalog=mydatabase

关于mysql - 尝试使用 DSN 连接到 MySql 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18209656/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com