Using web.config in compiled code
Messages   Related Types
This message was discovered on ASPFriends.com 'aspngconfig' list.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.

Jon Maz
-- Moved from [aspngfreeforall] to [aspngconfig] by Yannick Smits <Click here to reveal e-mail address> --

Hi,

The following code works fine when used in a normal aspx page:

Dim objConn as New OleDbConnection (
ConfigurationSettings.AppSettings("ConnectionString") )

However, when I put this exact same line in a function in a .vb file, on
compilation into the /bin folder I get the following error:

C:\Inetpub\wwwroot\Database.vb(172) : error BC30451: Name
'ConfigurationSettings' is not declared.

Can anyone tell me what I'm doing wrong, and how to fix it?

Thanks in advance,

JON

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.351 / Virus Database: 197 - Release Date: 19/04/2002

Reply to this message...
 
    
Yannick Smits (VIP)
In the code behind the System.Configuration namespace is not included by =
default. So change your code into:
System.Configuration.ConfigurationSettings.AppSettings("ConnectionString"=
)=20
or add a reference at the top of your page.

hth,
Yannick Smits

----- Original Message -----
From: "Jon Maz" <Click here to reveal e-mail address>
To: Click here to reveal e-mail address
Sent: Mon, 6 May 2002 23:53:25 +0200
Subject: Using web.config in compiled code
[Original message clipped]

Reply to this message...
 
    
Jon Maz
Hi,

Of course, I had forgotten to import System.Configuration! Now the .vb file
works fine.

Thanks for the help,

JON

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.351 / Virus Database: 197 - Release Date: 19/04/2002

Reply to this message...
 
 
System.Configuration.ConfigurationSettings
System.Data.OleDb.OleDbConnection




Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
 
 Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us - Terms of Use - Privacy Policy - www.dotnet247.com