0

(Tearing my hair out, been doing this a million times for decades and now it doesn't work!) I have a simple VB6 program, connecting to SQL 2008 Express locally on the host machine. I can connect to the database using the same credentials in SQL Server Management Studio Express. However, when I run this code, I get the following error:

Run-time error '3706': Method 'Open' of object '_Connection' failed

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

Here's the connection string: Provider=SQLOLEDB.1;Persist Security Info=False;Initial Catalog=MyDatabase;Data Source=R19DEV\SQLEXPRESS;User ID=MyUser;Password=MyPassword

Jay Imerman
  • 4,475
  • 6
  • 40
  • 55

1 Answers1

1

OK, I'm not sure why this worked. I changed the connection provider from SQLOLEDB.1 to SQLOLEDB, and that fixed it.

Jay Imerman
  • 4,475
  • 6
  • 40
  • 55