ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Database Connection Password (https://www.excelbanter.com/excel-programming/423313-database-connection-password.html)

detrie

Database Connection Password
 
I created an Excel file that queries an Access database that is
password protected. The
file has multiple pivot tables that have SQL connection to the
database.

When I try to refresh these pivot tables I get a dialog box asking me
to provide authorization to the data
source (Login name is supplied, password is not). If I were the only
user I would consider this an unfortunate inconvenience, but I created
this Excel file to allow other users to access data in specific tables
and not have access to the whole database. Excel asking for a
password pretty much kills the purpose of the file.

Is there an elegant way to put this password into the Connection?

Terry

detrie

Database Connection Password
 
Just a follow-up to anyone in future who has a similar question.
You can go into the properties of the database connection and save the
password.
In Excel 2007: Data Ribbon -- Connections Group -- Properties.
From that dialog box, click on Definitions and click Save Password.

In VBA:

Sub Initialize()
Dim CNN As WorkbookConnection
'...
'... (lots of code setting up the pivot tables)
'...
For Each CNN In ActiveWorkbook.Connections
CNN.ODBCConnection.SavePassword = True
Next CNN
End Sub


All times are GMT +1. The time now is 01:45 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com