CodeVerge.Net Beta


   Explore    Item Entry   Register  Login  
Microsoft News
Asp.Net Forums
IBM Software
Borland Forums
Adobe Forums
Novell Forums




Can Reply:  No Members Can Edit: No Online: Yes
Zone: > NEWSGROUP > Asp.Net Forum > starter_kits_and_source_projects.dotnetnuke.custom_modules Tags:
Item Type: NewsGroup Date Entered: 3/20/2006 9:03:37 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
NR
XPoints: N/A Replies: 1 Views: 263 Favorited: 0 Favorite
2 Items, 1 Pages 1 |< << Go >> >|
jbeall
Asp.Net User
Accessing Web.config values programmatically3/20/2006 9:03:37 PM

-1

Hi All,

Can you help me with this bit of code?  I'm trying to get the connection string from my web.config file, which looks something like this:

<configuration>
  <connectionStrings>
    <add name="SiteSqlServer" connectionString="Server=localhost;Database=DNN4_module_dev;uid=secret;pwd=supahdupahsecret;" providerName="System.Data.SqlClient" />
  </connectionStrings>
</configuration>

Then I've got this bit of code:

Dim configAccess As System.Configuration.Configuration = WebConfigurationManager.OpenWebConfiguration("\")
            HttpContext.Current.Trace.Write("SiteSqlServer", configAccess .ConnectionStrings.ConnectionStrings("SiteSqlServer").ConnectionString)


But I get an error about "Object reference not set to an instance of an object."

So the bottom line for me is: how am I supposed to access my connection string in Web.config programmatically?

Incidentally I can't alter the Web.config schema.  I'm using DotNetNuke and that's how it needs the Web.config arranged.

Thanks for any pointers on this!

-jb
StrongTypes
Asp.Net User
Re: Accessing Web.config values programmatically3/20/2006 9:22:46 PM

0

System.Web.Configuration.WebConfigurationManager.ConnectionStrings("SiteSqlServer").ConnectionString

HTH,
Ryan


Ryan Olshan
Microsoft MVP, ASP.NET
Blog | Group | Website | Strong Coders Community

How to ask a question
2 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
Visual Basic .NET developer's guide to ASP.NET, XML, and ADO.NET Authors: Jeffrey P. McManus, Chris Kinsman, Pages: 592, Published: 2002
Pro VB 2005 and the .Net 2.0 platform Authors: Andrew Troelsen, Pages: 1034, Published: 2006
Pro C# 2008 and the .NET 3.5 platform Authors: Andrew Troelsen, Pages: 1370, Published: 2007
Microsoft.NET XML Web Services Authors: Robert Tabor, Pages: 464, Published: 2001
Beginning ASP.NET 3.5: In C# and VB Authors: Imar Spaanjaars, Pages: 734, Published: 2008

Web:
How to: Access ASP.NET Configuration Settings Programmatically The value is displayed on the Web page. ... Dim configPath As String = "/ MyAppRoot" ' Get the configuration object to access the related Web.config file. ...
How To: Programmatically Add and Remove Web.config values You can add and remove configuration values in the Web.config file for a Web application programmatically, by using the SPWebConfigModification class.
Accessing Web.config values programmatically - ASP.NET Forums So the bottom line for me is: how am I supposed to access my connection string in Web.config programmatically? ...
Programming the web.config File Using C# The following method can be used to modify a specific key — value pair of the web.config file — programmatically using C#: public void Modify(string key, ...
access web.config programmatically asp.net VB and set sql query ... 1) connecteing to the database from web.config. 2) inserting variable values into the sql select statment ...

Accessing Web.config values programmatically - ng.asp-net-forum ... Accessing Web.config values programmatically, > ROOT > NEWSGROUP ... supposed to access my connection string in Web.config programmatically? ...
How to refresh tree view programmatically using C#? - ng.asp-net ... Even if modifying a web.config file programmatically can be a handy ... urgent: from code behind cannot access aspx page variables inside ...
gmail config on web.config - ng.asp-net-forum.security How to put the 'PORT' and 'SSL' attributes on web.config ? ... Get free web- based email from Yahoo! Access email from anywhere, enjoy unlimited storage ... how can you remove a profile property value (so it reverts to returning default) ... programmatically added web parts disappear on postback ...
web.config, allow anonymous access to only some pages - ng.asp-net ... web.config, allow anonymous access to only some pages, > ROOT > NEWSGROUP > Asp. Net Forum ... programmatically folder authorization ...
Unable to encrypt web.config - ng.asp-net-forum.security Unable to encrypt web.config, > ROOT > NEWSGROUP > Asp.Net Forum > general_asp. net.security, ... I have verified NETWORK SERVICE has read/write access to C:\ Documents and ... Encrypting Web.Config Values in ASP.NET 2.0 - ScottGu's Blog Our web.config ... adding access rules programmatically ...






dotnetnuke and microsoft reporting services

secure private assemblies

menu always return to home page

download magichyperredirect

searching "reminder" and "newest content" modules

pdf exporter of formatted documents

module wrapper 4.0 is released

e-commerce

weather module (v1.5.4) for dnn 3.1.0

ann: takeout express 1.0.2

minimize maximize viewstate across tabs

where isthe banner module ?

html/text module: text vs raw

sending to search engines

magicchat 1.2 sr2 released

anyone developing c# modules for integration into dnn?

using module.css within visual studio .net's ide

i am looking for a free announcements module...

send email from dnn

idea for a new module

a few module building questions

dnn load failed - 'version' element has an invalid value

new module development

forums with integrated authentication

how would i go about this?

async web request processing examples

in article 3.2 ??? replace russian letters

chat for dotnetnuke (source vb.net)

myblog v01.02.06 for dnn 2.1.2

problem with connected dropdown-lists. works only when logged on.

   
  Privacy | Contact Us
All Times Are GMT