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.
Provide the Windows service user name and password in the Microsoft SQL Server connection properties. Select the provider type as ODBC. Select the Use DSN check box. Click OK to create the connection.
Right-click on your connection and select "Properties". You will get the Properties window for your connection. Find the "Connection String" property and select the "connection string". So now your connection string is in your hands; you can use it anywhere you want.
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With