Defining ConnectionString in web.config and using in .aspx page.
Here we are going to read that how can be define the ConnectionString in web.Config file after defining how can be use this connnection string in our asp.net page.
When we define ConnetionString in web.config then there is no need to write ConnetionString in every asp.net page where we require SQL DDL,DML etc .
So first of all open you web.config and if there is not then add this in your project and write this code under Tag __
Here name="connetion" you can give anyname here we will call only this name in your code-behind code for connection and rest are connection details which you can how to give.
[Visual C# code]_____
Now in C# code
string dbstring = ConfigurationManager.ConnectionStrings["connection"].ConnectionString;
System.Data.SqlClient.SqlConnection sqlcon = new System.Data.SqlClient.SqlConnection(dnstring);
//Perform data operations
Now all the works done type this c# in every place where you want sqlconnection |:-)
If this helped you then please leave your precious comment.