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?
 
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
 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.