runtime error "-2147217843 on SQL server connection

S

stephenc

I'm having a problem with an SQL connection (MS SQL Server). Below is my
current connection string:

Dim myServer As String, myDatabase As String
Dim myUID As String, myPassword As String

myServer = "Paris"
myDatabase = "Documents"
myUID = "admin"
myPassword = "test"

sConnectionString = "driver={SQL Server};" & _
"server=" & myServer & ";database=" & myDatabase & _
";uid=" & myUID & ";pwd=" & myPassword

Set Conn = New ADODB.Connection
Set rs = New ADODB.Recordset
Conn.Open sConnectionString

On execution I'm getting runtime error "-2147217843 [Microsoft][ODBC SQL
Server Driver][SQL Server]Login failed for user 'admin'.

The test my setup, I have made a connection to the database via the relevant
wizard in Excel 2007, so the ODBC setup in Data Sources (Control Panel) is
good.

I'd really appreciate some input on this please. Any ideas what I'm doing
wrong?

Regards,
Stephenc
 
R

Russ

If you msgbox sConnectionString, does it look good.
Also try
Conn.Open chr(34) & sConnectionString & chr(34)

I think 34 is for a double quote.
I'm having a problem with an SQL connection (MS SQL Server). Below is my
current connection string:

Dim myServer As String, myDatabase As String
Dim myUID As String, myPassword As String

myServer = "Paris"
myDatabase = "Documents"
myUID = "admin"
myPassword = "test"

sConnectionString = "driver={SQL Server};" & _
"server=" & myServer & ";database=" & myDatabase & _
";uid=" & myUID & ";pwd=" & myPassword

Set Conn = New ADODB.Connection
Set rs = New ADODB.Recordset
Conn.Open sConnectionString

On execution I'm getting runtime error "-2147217843 [Microsoft][ODBC SQL
Server Driver][SQL Server]Login failed for user 'admin'.

The test my setup, I have made a connection to the database via the relevant
wizard in Excel 2007, so the ODBC setup in Data Sources (Control Panel) is
good.

I'd really appreciate some input on this please. Any ideas what I'm doing
wrong?

Regards,
Stephenc
 
S

stephenc

chr(34) solves my problem. Yes, 34 is the double quote character.

Thanks for helping me. it is much appreciated :)

Stephenc


Russ said:
If you msgbox sConnectionString, does it look good.
Also try
Conn.Open chr(34) & sConnectionString & chr(34)

I think 34 is for a double quote.
I'm having a problem with an SQL connection (MS SQL Server). Below is my
current connection string:

Dim myServer As String, myDatabase As String
Dim myUID As String, myPassword As String

myServer = "Paris"
myDatabase = "Documents"
myUID = "admin"
myPassword = "test"

sConnectionString = "driver={SQL Server};" & _
"server=" & myServer & ";database=" & myDatabase & _
";uid=" & myUID & ";pwd=" & myPassword

Set Conn = New ADODB.Connection
Set rs = New ADODB.Recordset
Conn.Open sConnectionString

On execution I'm getting runtime error "-2147217843 [Microsoft][ODBC SQL
Server Driver][SQL Server]Login failed for user 'admin'.

The test my setup, I have made a connection to the database via the relevant
wizard in Excel 2007, so the ODBC setup in Data Sources (Control Panel) is
good.

I'd really appreciate some input on this please. Any ideas what I'm doing
wrong?

Regards,
Stephenc
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top