how to write connection string in web.config file and read from it in

How to: Read Connection Strings from the Web.config File?

Look at below connectionstring code:

       <add name="Your Connection string name" connectionstring="data source=server name;
        Database=database name;uid=Database Username;pwd=password;
        multipleactiveresultsets=true;" providername="System.Data.SqlClient" />

For call connection string write the below code:

SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings
["Connection string name"].ConnectionString.ToString());

Connection string name means your connection name:

About the Author