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
******************************************
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
******************************************