Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Basics
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old September 15th, 2006, 08:13 PM
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.
  #2 (permalink)  
Old September 18th, 2006, 06:53 AM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Is your web.config in the root directory of your application?

Have you tried just writing the value to the screen as opposed to actually trying to use it? (e.g. Response.Write(ConfigurationSettings.AppSettings("[keyname]"))

I store all of my database connection strings in the web.config file and do something like this:

web.config:
<appSettings>
<add key="Clients" value="workstation id=PC;user ID=Username;password=Password;data source=Server;persist security info=True;initial catalog=Database"/>
</appSettings>

In code:

sqlConn = New SqlConnection
sqlConn.ConnectionString = ConfigurationSettings.AppSettings("Clients")

And this works fine.

--Stole this from a moderator

I will only tell you how to do it, not do it for you.

Unless, of course, you want to hire me to do work for you.
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Logins stopped working after adding to web.config troyb BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 5 September 2nd, 2008 03:34 PM
Web service not working properly in IIS Abhinavnaresh ASP.NET 2.0 Professional 1 April 10th, 2008 08:53 AM
window.opener working .... not working alyeng2000 Javascript How-To 5 January 5th, 2007 08:05 AM
Local COM working , but not working at Web Serv nagen111 .NET Web Services 3 February 19th, 2005 04:22 AM



All times are GMT -4. The time now is 02:07 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.