How to maintain ASP.NET Connection string in Web.config
Some time we need to store connection strings in web.config file .The below is the code to add connection string to web.config.file
<configuration> <appSettings> <add key=”ConnectionString” value=”server=localhost;uid=sa;pwd=;database=testdatabase” /> </appSettings> </configuration>
You can change the connection string according to your requirement.here i am specifying a connectionstring for accessing data from the same server (therefor server : localhost) and the database name is testdatabase.
How do we access this from our ASP.NET pages ? This way it is
We need to include System.Configuration namespace
using System.Configuration;
string connectionString = (string )ConfigurationSettings.AppSettings["ConnectionString"];
Categories: ASP.NET

Just a quick question. How wil you use Windows Integrated Authenticatio with ? Why cant you use instead which has option for integrated security.
We can use Windows Integrated Security too to create a connection.At that time we would be using windows user credentials. But in a scenario where web server (infact IIS ) is different from the DB server, This is not ideal to use