It is a good practice to store the connection string for your application in a config file rather than as a hard coded string in your code. The way to do this differs between .NET 2.0 and .NET 3.5 (and above). This article covers .NET 3.5 and above.
In the Previous articles i explained how to integrate ckeditor with asp.net, how to upload image to the server or application using Ckeditor , how to change or set width of ckeditor textbox area using asp.net, how to set or change height of Ckeditor textbox area using ASP.Net, integrate custom image uploader control with ckeditor using asp.net, how to add asp.net membership tables to the existing database and many more about Asp.Net.
Connection string in .NET 3.5 (and above) config file
Open your web.config File.
Do not use appsettings in web.config. Instead use the connectionStrings section in web.config.
Locate <configuration> tab and put the connection string between them like below.
<add name="database_con" connectionString="Data Source=MY-PC\SQLEXPRESS;Initial Catalog=DB1;Integrated Security=True" providerName="System.Data.SqlClient"/>
You have successfully created your connection string.
In above config file database_con is a connection string. It is separated from source code because you can change the config file any time and don’t need to compile the source code.
NOTE : Always store the connection string in a config file. It's not any harder once you get used to it and you will benefit from it as it is much easier to change connection string properties when your application is in production.