I am setting the connection string as follows but I'm getting an error that states "The ConnectionString property has not been initialized." I used the command window in VS2005 and found out that "ConfigurationManager.AppSettings["ConnxString"]" is returning a null value. I set it in my web.config as follows. Why am I getting a null value?
my code
Code:
SqlConnection objConnection = new SqlConnection(ConfigurationManager.AppSettings["ConnxString"]);
my web.config
Code:
<?xml version="1.0"?>
<!--
Note: As an alternative to hand editing this file you can use the
web admin tool to configure settings for your application. Use
the Website->Asp.Net Configuration option in Visual Studio.
A full list of settings and comments can be found in
machine.config.comments usually located in
\Windows\Microsoft.Net\Framework\v2.x\Config
-->
<configuration>
<appSettings />
<connectionStrings>
<!-- "Data Source=LAPTOP;Initial Catalog=RODEOMOUNT;Integrated Security=True" -->
<!-- Live string "Data Source=tcp:sql2k510.discountasp.net;Initial Catalog=SQL2005_548493_rodeomount;User ID=SQL2005_548493_rodeomount_user;Password=******;" -->
<add name="ConnxString" connectionString="Data Source=LAPTOP;Initial Catalog=RODEOMOUNT;Integrated Security=True" />
</connectionStrings>
<system.web>
<!--
Set compilation debug="true" to insert debugging
symbols into the compiled page. Because this
affects performance, set this value to true only
during development.
-->
<compilation debug="true"/>
<!--
The <authentication> section enables configuration
of the security authentication mode used by
ASP.NET to identify an incoming user.
-->
<authentication mode="Windows"/>
<!--
The <customErrors> section enables configuration
of what to do if/when an unhandled error occurs
during the execution of a request. Specifically,
it enables developers to configure html error pages
to be displayed in place of a error stack trace.
<customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
<error statusCode="403" redirect="NoAccess.htm" />
<error statusCode="404" redirect="FileNotFound.htm" />
</customErrors>
-->
</system.web>
</configuration>