View Single Post
  #1 (permalink)  
Old September 15th, 2006, 08:13 PM
peace95 peace95 is offline
Friend of Wrox
Points: 793, Level: 10
Points: 793, Level: 10 Points: 793, Level: 10 Points: 793, Level: 10
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2005
Location: OKC, OK, USA.
Posts: 227
Thanks: 1
Thanked 7 Times in 7 Posts
Default Web.Config..Working or Not Working

I am trying to use the web.config index property specifying the Connection String of an SQL db files. According to the documentation, u add the following code to web.config-
Lines inserted after </system.web> and before </configuration>:
<appSettings>
  <add key="NWind"
 value="server=(local); database=northwind4; integrated security=true;"/>
</appSettings>
</configuration>
In my .aspx program, Datareader, inserted after Sub Page_Load statement add the following:

Dim strConnection As String = Configuration.AppSettings("NWind")

Running the program generates the error: The Connection String property has not been initialized, with the Connection.Open() highlighted. This indicates to me, the .aspx program is not finding the SQL files Connection string in web.config.

I also tried the GetConfig("appSettings") prior to Dim strConnection stastement above.

I also tried:
Dim objConnection As New SqlConnection(ConfigurationSettings.AppSettings("N Wind"))

I am still getting the Connection string property has not been initialized.

My web.config file is located in the following directory:
C:\Inetpub\wwwrootAlso in my IIS Default WebSite folder.

I have a project that could use this function, so any help would be appreciated.

Thanks in advance.
__________________
Disclaimer: The above comments are solely the opinion of one person and not to be construed as a directive or an incentive to commit fraudulent acts.