Results 1 to 7 of 7
  1. #1
    Join Date
    Mar 2004
    Posts
    11

    Unanswered: passing password to connectionstring

    Does anyone know how to pass a variable (in my case value of password) to the connectionstring?

    I was hoping it would have been as easy as the following:

    spCON->ConnectionString = L"driver={sql server};SERVER=SEW01178;uid=user;pwd=" & pword & ";Database=TestlDB;";

    but of course it wasn't. Any help would be appreciated!

    Thx
    Eric2000

  2. #2
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    Did you really name your login "user" for this test??? That sounds like a receipe for a disaster to me!

    -PatP

  3. #3
    Join Date
    Mar 2004
    Posts
    11
    What I'm trying to do is encrypt the password first before I "insert" it in the connectionstring. I've got the password encrypted but don't know how to insert it into the connectionstring.
    thx
    eric2000

  4. #4
    Join Date
    Mar 2004
    Posts
    11
    No, that id was just a sample one I used for this post...

  5. #5
    Join Date
    Mar 2004
    Location
    www.scirocco.ca
    Posts
    346

    Re: passing password to connectionstring

    Are you using ADO? It should work as long as the server can un-encrypt the password. Try doing the same but without encrypting this time to see if the encryprion is the problem.

    Another way is to use the properties of the ADO Connection Object as follows:

    cn.Properties("Password").Value = sPassword
    http://www.scirocco.ca/images/banner...occobanner.gif

    Download for FREE the ADO/DAO Data Controls that makes life EASIER developing database applications in: VB, FoxPro, Access, VC++, .NET etc... Navigate, Add New, Delete, Update, Search, Undo and Save your changes. Supports Disconnected Recordsets and Transactions!

    Or try our Ask An Expert service to answer any of your questions!

  6. #6
    Join Date
    Mar 2004
    Posts
    11
    Thanks Scirocco for the reply...
    Yes, I am using ADO. I had the connectionstring working before encryption but must encrypt for security reasons. I am decrypting the password and then passing the decrypted password to the connectionstring so I am not sure what you mean by "it should work as long as the server can un-encrypt the password. "

    I am not able to get the following working:
    cn->Properties("Password")->Value = sPassword

    I get the following errors when I complile
    error C2064: term does not evaluate to a function
    error C2227: left of '->Value' must point to class/struct/union

    thx again
    eric2000

  7. #7
    Join Date
    Mar 2010
    Posts
    1

    C#/IIS solution

    Look here for a .Net solution to encrypting a password in a connection string.
    My Blog

Posting Permissions

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