C # referencing connectionstring in Web. config
<connectionStrings>
<add name= "jkxtconnectionstring" connectionstring= "Data source=chf;initial catalog=jkxt; User id=sa"providername=" System.Data.SqlClient "/>
<add name= "jgxtconnectionstring" connectionstring= "Data source=chf;initial catalog=jgxt; User Id=sa "providername=" System.Data.SqlClient "/>
</connectionStrings>
<connectionStrings>
<add name= "db_emsconnectionstring" connectionstring= "Data source=85ddbbbfa5a34f9;initial Catalog=DB_EMS; Integrated security=true " providername=" System.Data.SqlClient "/>
</connectionStrings>
The way to get it is:
configurationmanager.connectionstrings["Jgxtconnectionstring"]. ConnectionString;
or so write Web. config
<appSettings>
<add key= "ConnectionString" value= "Data source=chf;initial catalog=jgxt; User Id=sa "/>
</appSettings>
<appSettings>
<add key= "Dbhelperprovider" value= "System.Data.SqlClient"/>
<add key= "dbhelperconnectionstring" value= "Data source=85ddbbbfa5a34f9;initial catalog=db_ems; Integrated security=true"/>
</appSettings>
The methods to obtain this are:
configurationsettings.appsettings["Jgxtconnectionstring"];
Reference using System.Configuration;
C # referencing ConnectionString in Web. config