If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Delphi, C etc > passing password to connectionstring

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-21-04, 12:57
eric2000 eric2000 is offline
Registered User
 
Join Date: Mar 2004
Posts: 11
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
Reply With Quote
  #2 (permalink)  
Old 04-21-04, 13:26
Pat Phelan Pat Phelan is offline
Resident Curmudgeon
 
Join Date: Feb 2004
Location: In front of the computer
Posts: 12,606
Did you really name your login "user" for this test??? That sounds like a receipe for a disaster to me!

-PatP
Reply With Quote
  #3 (permalink)  
Old 04-21-04, 13:30
eric2000 eric2000 is offline
Registered User
 
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
Reply With Quote
  #4 (permalink)  
Old 04-21-04, 13:31
eric2000 eric2000 is offline
Registered User
 
Join Date: Mar 2004
Posts: 11
No, that id was just a sample one I used for this post...
Reply With Quote
  #5 (permalink)  
Old 04-21-04, 14:04
SCIROCCO SCIROCCO is offline
Registered User
 
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!
Reply With Quote
  #6 (permalink)  
Old 04-21-04, 14:43
eric2000 eric2000 is offline
Registered User
 
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
Reply With Quote
  #7 (permalink)  
Old 03-08-10, 12:45
Don Frederick Don Frederick is offline
Registered User
 
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
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On