+ Reply to Thread
Results 1 to 3 of 3

How do I edit data connection string or save database credentials for end user?

  1. #1
    Forum Contributor
    Join Date
    04-14-2008
    Location
    Fort Collins, Co
    MS-Off Ver
    2016
    Posts
    107

    Question How do I edit data connection string or save database credentials for end user?

    I have a data connection that runs a SQL query using power query. All I want to do is add to the connection string the username and password so that my data customers do not have to enter it. However, the connection string settings are greyed out for this item. Maybe I need to change to ODBC database connection because SQL connection will not allow me to save the database username and password?
    Is That Your Spreadsheet Or Did Your Database Just Throw Up?


  2. #2
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,910

    Re: How do I edit data connection string or save database credentials for end user?

    I am not familiar with the connections for Power Query, but I am familiar with the connections for some ODBC connections. Go to the Data Ribbon, Select Connections. Select the connection you want. Right click it and select Properties, Select the option to save password. This may be all you need for your end user to do. However, the user name and password are stored in the connection string in the clear. They are not encrypted.

    If you are OK with this then we're done. You really can't protect a connection or anything else in a workbook, from a determined hacker, but you can make it more difficult for prying eyes to see. You can put in some code to refresh data that inserts the credentials, runs the query and then deletes the credentials. Or in a more trusting environment, you may want to type in the user name and password into cells and "configure" the connections.

    Both require knowing how the connection string is formatted.

    An ODBC connection looks something like: ODBC;DSN=RPTPRD01;UID=dflak;PASSWORD;DBQ=RPTPRD01;DBA=W;APA=T;EXC=F;FEN=T;QTO=T;FRC=10;FDL=10;LOB=T;RST=T;BTD=F;BNF=F;BAM=IfAllSuccessful;NUM=NLS;DPM=F;MTS=T;MDI=F;CSR=F;FWC=F;FBS=64000;TLO=O;MLD=0;ODA=F;

    Different databases have different formats.

    To get this I used the following code:
    Please Login or Register  to view this content.
    Intelisense may help. You may have to type in something other than ODBCConnection. I don't know what is appropriate for Power Query.

    This will give the format of the connection string. Then do as I did, change the real password to PASSWORD and post it here.

    If you can't get the VB to work then second best is to copy / paste the contents of the Properties dialog box.

    Changing credentials is a matter of pulling apart the connection string into its components, changing the two parts corresponding to the user name and password and gluing it back together
    One spreadsheet to rule them all. One spreadsheet to find them. One spreadsheet to bring them all and at corporate, bind them.

    A picture is worth a thousand words, but a sample spreadsheet is more likely to be worked on.

  3. #3
    Forum Contributor
    Join Date
    04-14-2008
    Location
    Fort Collins, Co
    MS-Off Ver
    2016
    Posts
    107

    Re: How do I edit data connection string or save database credentials for end user?

    Thank you. I'll mess around with this. I'm thinking the issue is that I don't actually have an ODBC connection to pull the data. I'm using a SQL query through Power Query. I can probably rebuild the SQL into ODBC direct connection and pull the data in that way. I think then I'll be able to access the connection string.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. looking for sample code that upload files to SharePoint using the user credentials
    By jpandino in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-17-2015, 05:39 PM
  2. SendKeys to Automate DB Connection Credentials Prompt
    By AlvaroSiza in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-24-2013, 05:41 PM
  3. Replies: 2
    Last Post: 07-05-2013, 09:37 AM
  4. Pass credentials to Access from Excel for an ODBC connection
    By Jasrenkai in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-06-2011, 03:13 PM
  5. Replies: 0
    Last Post: 07-20-2006, 12:20 PM
  6. Using classes to store user credentials
    By Philippe Pons in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-03-2005, 12:05 PM
  7. [SOLVED] how do i directly edit a connection string in an Excel workbook q.
    By SteveCarlston in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-14-2005, 09:06 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1