Hello everyone,
I am using VSTS 2010 + C# + .Net 4.0 to develop an ASP.Net application using SQL Server 2008 Enterprise as database. I am learning someone else's code. I notice code like this, I am not sure whether the usage is correct and so I come here to ask for advice.
In the code, I see some code like this, I want to know whether using such method to read connection string from web.config is correct?
ConfigurationManager.ConnectionStrings["DBConnectinString"].ConnectionString
and such code is used to read connection string from web.config like below, please notice that connection string is defined outside of system.web section.
<?xml version="1.0"?>
<configuration>
<configSections>
<!--this section is empty-->
</configSections>
<appSettings>
...... content of appSettings
</appSettings>
<connectionStrings>
<add name="DBConnectinString" connectionString="data Source=.;uid=foo;pwd=foo;database=FOODB" providerName="System.Data.SqlClient"/>
</connectionStrings>
<system.web>
... ... content of system.web
</system.web>
</configuration>
thanks in advance, George