Excel VBA - connect to sql with a trusted connection (no uid/pwd)

notnot picture notnot · Oct 15, 2009 · Viewed 78.5k times · Source

Is there a way to have Excel connect to Sql Server using the current user's network windows authentication (trusted connection/integrated security)? I don't want to rely on a sql login or have a uid/password in my code.

Answer

El Ronnoco picture El Ronnoco · May 27, 2011

I have this connectionstring in an Excel 2003 VBA project...

"Provider=SQLOLEDB;Data Source=[You DB Name];Trusted_connection=yes;"

And it works for me! (I'm using ADODB)