can't connect remote SQL server

D

d

I am trying to connect SQL remote server. "BA"
and get error
@@@@"-2147217843"/Automation Error @@@@@@@@@

I have created a database name "archives" in Server "BA".

the data base I transfered from my (local) server into BA
with same database name and tables.

Now I can connect into the (local) one, but I can't
connect the remote "BA".

I used ODBC config, and both local and BA.
passed the testing.

What is wrong in my code?

Thanks in advance.

d

code below:
************************************
Dim cn As ADODB.Connection
Dim Rs As ADODB.Recordset



Dim StrSQL As String
Dim LngRecsAff As Long

Set cn = New ADODB.Connection
Set Rs = New ADODB.Recordset

MsgBox "1"
'always don't change "SQLOLEDB"
'change USer ID=****sa****
'change Initial Catalog=****ww_try_DB*****. -----
"ww_try_db" is the database name------
With cn
.Provider = "SQLOLEDB"
.ConnectionString = "User ID=sa;Password=sa;Data
Source=(local)or BA;" & "Initial Catalog=archives"
.Open

End With

MsgBox "2"
Rs.CursorType = adOpenKeyset
Rs.LockType = adLockOptimistic
Rs.Open "State ", cn, , , adCmdTable
MsgBox "3"
While Not Rs.EOF
ComboBox1.AddItem Rs!Abbreviation
Rs.MoveNext
Wend
Rs.Close
cn.Close
MsgBox "4"

End Sub

******************************************
 

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