Dim SQLCON As ADODB.Connection
Dim SQLRS As ADODB.Recordset
' Set the ADO SQLCON properties.
Set SQLCON = New ADODB.Connection
Set SQLRS = New ADODB.Recordset
With SQLCON
.ConnectionTimeout = 25 ' Time out for the SQLCON
.Provider = "sqloledb" ' OLEDB Provider
.Properties("Network Address"

.Value = "999.999.999.999" ' Set the ip address of your sql server
.CommandTimeout = 180 ' Set timeout for 3 minutes
.Properties("Network Library"

.Value = "dbmssocn" ' Set the network library to use win32 winsock tcp/ip
.CursorLocation = adUseServer ' For ADO cursor location
.Properties("User ID"

.Value = "xx" ' Set the user id
.Properties("Password"

.Value = "xxxxxxxxxxxxxx" ' Set the password
.Properties("Data Source"

.Value = "999.999.999.999" ' Set the ip address as the datasource
.Properties("Initial Catalog"

.Value = "xxxxxxxx" ' Set the database name
.Open
End With
With SQLRS
.Open "SELECT * FROM TABLENAME;", SQLCON, adOpenStatic, adLockReadOnly, adCmdText
End With
SQLRS.Close
SQLCON.Close
Set SQLCON = Nothing
Swi