Click here to Skip to main content
15,920,438 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i need to read XML file to get connection string, I am using ASP.NET
How to read it ?

Thanks in advance
Posted
Updated 2-May-11 3:06am
v2
Comments
Umair Feroze 2-May-11 8:48am    
Please provide some structure of xml file
koolprasad2003 2-May-11 9:07am    
You connection is in WEB.CONFIG or in other xml file ?

You mean from Web.Config file right?

Check out this then : http://msdn.microsoft.com/en-us/library/ms178411.aspx[^]
 
Share this answer
 
Comments
RaviRanjanKr 2-May-11 11:17am    
Perfect Link,My 5 :)
Tarun.K.S 2-May-11 13:04pm    
Thanks ravi! And hey congrats for getting a platinum in Authority. I am still 3500 points away from it. Remarkable buddy! :)
RaviRanjanKr 2-May-11 23:42pm    
Thank you Tarun :)
Thanks for the Q n here is the ans
XML
<connectionStrings>
   <add name="Con1" connectionString="connectionstring"/>
 </connectionStrings>


C#
System.Configuration.ConfigurationManager.ConnectionStrings["Con1"].ConnectionString.ToString();
 
Share this answer
 
v2
Comments
RaviRanjanKr 2-May-11 11:17am    
Good Answer,My 5 :)
Steven.Pinto2000 3-May-11 5:08am    
Thanks 4 d 5
Wonde Tadesse 2-May-11 19:34pm    
Perfect !
If you are looking to read some configurations not from web.config but from some of the xml files of your own, then the following article provides you the information you are looking for:
Using XML in C# in the simplest way[^]

Hope this will help you
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900