Best Practice for storing connection strings in .net C# WIndows form applications.

Can someone tell me what the Best Practice is for storing connection strings in .net C# WIndows form applications.  I have a windows applications with several window forms that refer to EXCEL and SQL server connection strings.  How do you make these global in window form applications?

 strConnectionString = ExcelCon + "Data Source=" + strFileName + ";Extended Properties=" + Convert.ToChar(34).ToString() + "Excel 8.0;HDR=Yes;IMEX=1" + Convert.ToChar(34).ToString();

string cons = "Data Source=(local);Initial Catalog=MyDB;Integrated Security=SSPI;";
HojoformoAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

AkshCommented:
Hi,

The best place to store connection string is "always" in configuration file.

Please go through following link.
http://www.codeguru.com/columns/DotNet/article.php/c7987/

Let us know, if you still find difficutly.

Kind Regards,
Aksh
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
x77Commented:
When a server administrator migrates a DataBase or change the password for a Schema, it needs also migrate each Config.App for each user application.

I think this is´nt the best solution.

I use a Network-File to store a DataSet (Binary formatter) with Information about Connection Strings for some applications. Only Admistrator has write privileges for this archive.

Config.App has a variable that points to Network-File and other for the selected Connection-String.

0
nalla_btsCommented:
I would say go with the config files (as mentioned above) along with encryption.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.