Vb6 “ADO SQL Server”;方法';打开';对象的'_连接';“失败”;

Vb6 “ADO SQL Server”;方法';打开';对象的'_连接';“失败”;,vb6,ado,sql-server-2008-express,Vb6,Ado,Sql Server 2008 Express,(让我毛骨悚然,几十年来我一直在做这件事,但现在它不起作用!)我有一个简单的VB6程序,在主机上本地连接到SQL 2008 Express。我可以使用SQL Server Management Studio Express中相同的凭据连接到数据库。但是,当我运行此代码时,会出现以下错误: 运行时错误“3706”: 对象“\u连接”的方法“打开”失败 Dim DBConn As ADODB.Connection Set DBConn = New ADODB.Connection Dim ConnS

(让我毛骨悚然,几十年来我一直在做这件事,但现在它不起作用!)我有一个简单的VB6程序,在主机上本地连接到SQL 2008 Express。我可以使用SQL Server Management Studio Express中相同的凭据连接到数据库。但是,当我运行此代码时,会出现以下错误:

运行时错误“3706”: 对象“\u连接”的方法“打开”失败

Dim DBConn As ADODB.Connection
Set DBConn = New ADODB.Connection
Dim ConnString As String
txtServer.Text = "R19DEV\SQLEXPRESS"
txtCatalog.Text = "MyDatabase"
txtUser.Text = "MyUser"
txtPassword.Text = "MyPassword"
ConnString = "Provider=SQLOLEDB.1;Persist Security Info=False;Initial Catalog=" & _
            txtCatalog.Text & ";Data Source=" & txtServer.Text & ";User ID=" & txtUser.Text & _
            ";Password=" & txtPassword.Text
Debug.Print ConnString
DBConn.Open ConnString
以下是连接字符串:
Provider=SQLOLEDB.1;持久安全信息=False;初始目录=MyDatabase;数据源=R19DEV\SQLEXPRESS;用户ID=MyUser;Password=MyPassword

好的,我不知道为什么会这样。我将连接提供程序从
SQLOLEDB.1
更改为
SQLOLEDB
,并将其修复