views:

116

answers:

2

I'm trying to test the connection of a GoDaddy SQL Server database. I'm getting an 'invalid connection string attribute.'

What's wrong with this script?

Dim cnn As ADODB.Connection
Dim canConnect As Boolean

Public Sub TestConnection()

    Set cnn = New ADODB.Connection   
    cnn.Open "Provider=sqloledb;Data Source=GoDaddyServer.com;Initial Catalog=dBase1;UserID=userID; Password='password';"   
    If cnn.State = adStateOpen Then
        canConnect = True
        cnn.Close
    End If   
MsgBox canConnect

End Sub
A: 

IIRC, you have to specify the Provider property outside the connection string like so:

Dim conn
Set conn = New ADODB.Connection
conn.Provider = "sqloledb"
conn.Open "Data Source=GoDaddyServer.com; Initial Catalog=dbase1; User ID=userid; Password=pass;"
Thomas
Thanks. I got it working. The key was placing the connection string in a separate object and passing that string to the connection object. The other key was changing the User ID parameter to 'Uid'. That's required for the 'Provider=sqloledb;
brohjoe
A: 

I have never seen a password quoted in a SQL Server connection string like you have. Try removing the quotes:

"Provider=sqloledb;Data Source=GoDaddyServer.com;Initial Catalog=dBase1;User ID=userID; Password=password;"   

You might find connectionstrings.com useful in the future.

Michael Petrotta
you're right. I took the tick marks off the password. Thanks.
brohjoe