Results 1 to 6 of 6

Thread: configSections in App.config confusion

  1. #1

    Thread Starter
    Lively Member carl_mathews200's Avatar
    Join Date
    May 2004
    Location
    Wales, UK
    Posts
    94

    configSections in App.config confusion

    I am trying to create custom sections in the App.config file and read in the values at runtime but it is really confusing me.

    If i have something like....

    Code:
    <configSections>
         <section name="connectionProfiles" type="? What Goes Here ?" />
    </configSections>
    
    <connectionProfiles>
         <connectionProfile name="Profile1" value="MyValue" />
         <connectionProfile name="Profile2" value="AnotherValue" />
         .......
    </connectionProfiles>
    How do i then load those values at runtime into my application. Any help will be greatly appreciated.

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    In web.config:

    Code:
    <configuration>
    	<configSections>
    		 <section name="db"  type="System.Configuration.NameValueFileSectionHandler, System, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
    		
    	</configSections>
    
    	<db>
    		<add key="ConnectionString" value="Data Source=(local);Initial Catalog=Northwind;Integrated Security=SSPI" />
    		<add key="SQLStatement" value="SELECT TOP 10 * FROM Orders;" />
    	</db>
    To access it:

    VB Code:
    1. strVariableName = System.Configuration.ConfigurationSettings.GetConfig("db")("ConnectionString").ToString

    Comprende vouz?

  3. #3
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687
    Where the F* did "PublicKeyToken" come from? Does it matter what the value is? And if it does, how does one come up with it?

    Tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  4. #4
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    Originally posted by techgnome
    Where the F* did "PublicKeyToken" come from? Does it matter what the value is? And if it does, how does one come up with it?

    Tg
    I don't have a F*ing clue! I had asked this question in this forum earlier, I got no answer. I had to rely on tidbits.

    Maybe someone can explain it to me as well. I'd really welcome that.

  5. #5
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687
    Originally posted by mendhak
    I don't have a F*ing clue! I had asked this question in this forum earlier, I got no answer. I had to rely on tidbits.

    Maybe someone can explain it to me as well. I'd really welcome that.
    Sorry mate, I thought maybe you knew something I didn't. sounds like the perfect time to fire up a .NETapp and see what falls out!

    TG
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  6. #6
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    Check to see if there's a difference in ASP.NET and VB.NET regarding the way it works.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width