All I'm saying is that if you can connect using a DSN, you almost certainly
can connect using a DSN-less connection string.
Take a look at Carl Prothman's site (there's a link to it on my page)
http://www.carlprothman.net/Default.aspx?tabid=90#ODBCDriverForSQLServer
He says to connect to SQL Server running on a remote computer (via an IP
address), use
oConn.Open "Driver={SQL Server};" & _
"Server=xxx.xxx.xxx.xxx;" & _
"Address=xxx.xxx.xxx.xxx,1433;" & _
"Network=DBMSSOCN;" & _
"Database=myDatabaseName;" & _
"Uid=myUsername;" & _
"Pwd=myPassword"
Where:
- xxx.xxx.xxx.xxx is an IP address
- 1433 is the default port number for SQL Server.
- "Network=DBMSSOCN" tells ODBC to use TCP/IP rather than Named
That means you'd need to modify the function declaration in my code from
Sub FixConnections(ServerName As String, DatabaseName As String)
to something like
Sub FixConnections( _
ServerName As String, _
DatabaseName As String, _
IPAddress As String, _
UserName As String, _
Password As String _
)
and the section
tdfCurrent.Connect = "ODBC;DRIVER={sql server};DATABASE=" & _
DatabaseName & ";SERVER=" & ServerName & _
";Trusted_Connection=Yes;"
to something like
tdfCurrent.Connect = "ODBC;Driver={SQL Server};" & _
"Server=" & ServerName & ";" & _
"Address=" & IPAddress & ",1433;" & _
"Network=DBMSSOCN;" & _
"Database=" & DatabaseName & ";" & _
"Uid=" & Username & ";" & _
"Pwd=" & Password & ";"