Results 1 to 3 of 3

Thread: xml

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2002
    Location
    London
    Posts
    678

    xml

    Hi,
    This is the c# code which retrieves the two names from the app.config file.

    private void GetSettings()
    {
    System.Collections.Specialized.NameValueCollection colNameVal = null;
    colNameVal = System.Configuration.ConfigurationSettings.AppSettings;
    strServer = colNameVal["ServerName"];
    strDatabase = colNameVal["DatabaseName"];
    }


    the xml in app.config:
    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
    <appSettings>
    <add key="ServerName" value="svr07" />
    <add key="DatabaseName" value="TradarBe" />
    </appSettings>
    </configuration>

    Do you know why the strServer and the strDatabase variables in the c# code are not returning the correct names?
    Thanks

  2. #2
    Fanatic Member
    Join Date
    Oct 2000
    Location
    Reading, UK
    Posts
    870
    Code:
    x = system.configuration.configurationsettings.appsettings("connectionString")
    can you get a collection of the values in one go?
    www.vb-tech.com
    .Net Freelance Development
    http://weblog.vb-tech.com/nick
    My blog

  3. #3
    Fanatic Member VBCrazyCoder's Avatar
    Join Date
    Apr 2003
    Posts
    681
    I didn't think so - I always use what you have posted nswan.

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