Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 242
notnot Avatar asked Oct 15 '09 17:10

notnot


People also ask

How do I setup a trusted connection in SQL server?

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.

How do I find the Connectionstring in SQL server?

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.


1 Answers

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)

like image 145
El Ronnoco Avatar answered Sep 29 '22 12:09

El Ronnoco