Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/65.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
尝试使用DSN连接到MySql时出错_Mysql_Vb6_Odbc_Dsn - Fatal编程技术网

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

尝试使用DSN连接到MySql时出错,mysql,vb6,odbc,dsn,Mysql,Vb6,Odbc,Dsn,使用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.Comma

使用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
Dim conn作为ADODB.连接
Dim cmd作为ADODB.Command
将rs设置为ADODB.Recordset
将sql设置为字符串
Set rs=New ADODB.Recordset
Set cmd=New ADODB.Command
Set conn=新的ADODB.连接
康涅狄格州开放的“DSN=AddressHealthcheck”rags评论(如上)不是解决方案,但它确实有助于找到它

当使用完整连接字符串时,错误消息不同且更有用,驱动程序无法加载

问题似乎是,因为我在一台64位机器上,所以它是64位驱动程序。VB6无法使用64位驱动程序,并且64位计算机上的ODBC连接管理器中未显示32位驱动程序


DSN不是我机器中的选项。

我使用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

64位系统中有两个ODBC管理工具。运行32位版本。或者最好还是放弃ODBC,为MySQL提供一个OLEDB提供程序。

我在劳动节(昨天)1号之前就已经在研究这个问题了。今天我意识到我昨天犯了一些错误,为了让它正常工作

Dim conexion作为新ADODB.连接

conexion.ConnectionString=“DSN=yourdsname” 开放式

别忘了

  • 在mysql服务器中创建一个拥有所需所有特权的用户
  • 指定服务器的名称或ip,从中连接到mysql
  • 使用正确的选项在客户端计算机上创建dsn并对其进行测试