Skip to content

Help to retrieve values from web.config file urgent please

ricardo rosa

Asked May 14, 2009, 7:03 AM EDT3 answers
Share
LinkedInX
Hi

I´m new in the c# business.
I need to store in a new text file, some values from a web.config file that has this tag

<add key="SqlConnectionString1" value="data source=Server\Instace;initial catalog=xpto;password=xpto;persist security info=True;user id=xpto;Enlist=True"/>



and i need to store at the value (data source=Server\Instace).

Can anyone help me please?

3 Answers

Know the answer? Post it. Somebody with the same question will find it here.

  • Niradhip Chakraborty
    0

    you can access it like this.

    string strValue = ConfigurationManager.AppSettings["SqlConnectionString1"];

    0
  • 0
    Thanks,

    And if i dont know exactly the name? Like all the names that have conn on it?
    0
  • Niradhip Chakraborty
    0

    No,you need to pass the key name to retrieve the value. Basically it’s a key value pair. Without the key you can’t fetch the value from web.config.

    0