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?
Help to retrieve values from web.config file urgent please
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Niradhip ChakrabortyRank #428 · 5.8K pointsPosted May 14, 2009, 7:30 AM EDT
you can access it like this.
string strValue = ConfigurationManager.AppSettings["SqlConnectionString1"];
ricardo rosa13 pointsPosted May 14, 2009, 7:42 AM EDT
And if i dont know exactly the name? Like all the names that have conn on it?
Niradhip ChakrabortyRank #428 · 5.8K pointsPosted May 14, 2009, 7:59 AM EDT
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.