I am trying to connect to SQL Server 2008 from Excel VBA using the connection string (ADODB.Connection).
"Driver={SQL Native Client};Data Source=" & Range("Svr").Value & ";Database=" & Range("DB").Value & ";Trusted_Connection=yes"
When I try to open the connection I get this error
Error (-2147467259) Description – [Microsoft][ODBC Driver Manager]
Data source name too long
Can some one please provide me a sample
I think the backslash in your connection string is causing your issues, try and escape it like so:
Also, putting quotes around each value wouldn’t hurt:
Based on this answer.