Although the new ado.net in VS 2K5 enables us to develop faster, we can even use the database code at all without handwriting, but sometimes we have to get ConnectionString. Write it here ...
The
========web.config file is ===========
<?xml version= "1.0"
<configuration xmlns= "http://" schemas.microsoft.com/. netconfiguration/v2.0 "
<configsections>
<section name=" DataConfiguration " Type= "Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data "/>
</configsections>
< Connectionstrings>
<remove name= "LocalSqlServer"/>
<add name= " LocalSqlServer "connectionstring=" Data source=.;i ntegrated security=true;initial catalog=morning2 "Providername= System.Data.SqlClient"/>
</ Connectionstrings>
<dataconfiguration defaultdatabase= "LocalSqlServer"/>
<!-- This sentence gives Enterpriselibrary.data a connection string with the
<system.web>
//
</system.web>
</configuration>
==================================
Use System.Configuration when used:
Connectionstringsettingscollection CSSC = System.Web.Configuration.WebConfigurationManager.ConnectionStrings;
String constr = cssc["LocalSqlServer"]. ConnectionString;
----------------or-----------------
String constr = configurationmanager.connectionstrings["LocalSqlServer"]. ConnectionString;