【问题标题】:ADO SQL Server, "Method 'Open' of object '_Connection' failed"ADO SQL Server,“对象 '_Connection' 的方法 'Open' 失败”
【发布时间】:2012-03-29 14:12:43
【问题描述】:

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

运行时错误“3706”: 对象“_Connection”的“打开”方法失败

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;Persist Security Info=False;Initial Catalog=MyDatabase;Data Source=R19DEV\SQLEXPRESS;User ID=MyUser;Password=MyPassword

【问题讨论】:

    标签: vb6 ado sql-server-2008-express


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-11-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多