Question Saving password within an application settings connection string

robtyketto

Member
Joined
Jul 23, 2009
Messages
23
Programming Experience
Beginner
Greetings,

I have encrypted my jet database (access 07) and to avoid hard coding my connection within the .net code, created a connection string in the application settings.

I discovered in the choose database source wizard has a tickbox "Remember password" is a red herring as it really doesnt save the password.

The test connection works, but you can't save the password, so my application has runtime errors.

Im a newbie but had a sneaky peek in the app.config and could see no password details.

Can anyone please advise if storing the connection string is a suitable way to avoid hardcoding it within the code and if it is how do I save the password to allow a connection?

Going slightly off topic, when I add the database (.accdb) to my project in the main application directory for publishing reasons its copied over to the release directory upon running the app.

For deployment purposes I assume that I should add files in the application folder from the main app directory and not reference those in the release directory?

Hope this problem is easy to understand :eek:

Thanks
Rob
 

cjard

Well-known member
Joined
Apr 25, 2006
Messages
7,052
Programming Experience
10+
Check ConnectionStrings.com - Forgot that connection string? Get it here! for how to make your connection string, then edit the app.config to contain the password. I never had a problem with it containing it though! The tickbox always saved my passwords?!

Yes, you use the "clean" version of your database, not the version you messed about with during testing the Release version

Given that your DB is set to be a part of your app (?) with a Copy To Output Directory set, I would expect the installer to include it, but you can ensure that your deployment project contains "Included Files" of the main release
 

robtyketto

Member
Joined
Jul 23, 2009
Messages
23
Programming Experience
Beginner
Check ConnectionStrings.com - Forgot that connection string? Get it here! for how to make your connection string, then edit the app.config to contain the password. I never had a problem with it containing it though! The tickbox always saved my passwords?!

Yes, you use the "clean" version of your database, not the version you messed about with during testing the Release version

Given that your DB is set to be a part of your app (?) with a Copy To Output Directory set, I would expect the installer to include it, but you can ensure that your deployment project contains "Included Files" of the main release

Thanks will check out that site, my connection string in the app settings is working OK at the moment as I removed the database password.

Had a quick scan on the web about various security measures as the app.config is installed in the program directory and hence readable to everyone.

So anyone can just examine the xml , write down the login and then go straight to the database (.accdb) and examine its contents :(
 
Top Bottom