Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Add password to connectionstring

Status
Not open for further replies.

ashishraj14

Programmer
Mar 1, 2005
92
0
0
AU
Creating a new typed dataset using the Data Source Configuration Wizard (and opting NOT to save the password with user settings) generates a ConnectionString setting like...

Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\JB74\LISYSTEM.MDB;User ID=user;Jet OLEDB:System database=C:\JB74\system.mdw

How do I now incorporate "password=xxx" without saving it in app.config?

Thanks
 
If you want users to enter the password at runtime, you could do this:

Say you have a logon screen with a textbox named - conveniently - Password.

The user enters the password and clicks the logon button.

The code behind that button takes the value entered in the Password textbox and includes it in the connection string like so:

Dim cs As String

cs = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\JB74\LISYSTEM.MDB;User ID=user;[red]Password=" & Password.Text.Trim & ";[/red]Jet OLEDB:System database=C:\JB74\system.mdw"

the code I added is in red.

I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson
 
Oops...hit Submit Post too soon.

You will need to do some sort of validation on the value entered into the Password textbox, such as making sure that it is not empty, etc.

I'll leave that part up to you.


I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson
 
You don't want the users to enter it at runtime but you don't want to add it at design time?

If you are saying that you don't want to add it at design time foe security reasons (e.g. as it may be stored as plain text) then you will have to encrypt the connection string and decrypt it when it needs to be used.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
I am working on this problem as well and need some help. I have an Access database which needs a password to open and it resides on the server (not user account passwords). How can I incorporate pwd into the connection string. In DAO for vb6 it was opendatabase("dbname;pwd=mypassword")- how can I do this with ADO.net ?
Thanks

fordtran
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top