Sponsored By
MindStick Cleaner
Advertise with Us
Advertisement
Advertise with Us
Follow Us
Follow _MindStick_ on Twitter View MindStick Software's LinkedIn profile View MindStick Software's Facebook profile
Mindstick
Article Article  Forum Forum  Blog Blog  Quiz Quiz  Beginner Beginner  Careers Careers  Contact Contact  Login Login  
Home | Product | Services | About Us | Interview | DeveloperSection | Submit an Article | Submit Blog
Report Abuse Form
Reason:    
   

Home >> .Net >> C# >> How to get connection string from app.config file in VC#.
Author Post

James Smith


Total Post: 48
Member Since: 3/16/2011
Points: 270
How to get connection string from app.config file in VC#.
Posted On: 7/30/2011 4:55:38 AM

Hi,

I would like to access connection string from app.config file but am not able to perform it. I am using C# as a programing language and visual studio 2010 IDE on windows 7 64 bit plateform.

Help needed.

Thanks.

Author Post

Uttam Misra


Total Post: 113
Member Since: 6/2/2010
Points: 818
Author Post

Awadhendra Tiwari


Total Post: 126
Member Since: 1/19/2011
Points: 893
Re: How to get connection string from app.config file in VC#.
Posted On: 7/30/2011 5:06:22 AM

Hi james,

You can use following line of code to access connection string from app.config file.

string cs = System.Configuration.ConfigurationSettings.AppSettings["cs"].ToString();
For this app.config file.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <appSettings>
    <add value="DataSource=a;User Id=ccc;" key="cs"/>
  </appSettings>
</configuration>
Thanks.
Report Abuse Form
Reason:    
 
Total Online Users: 4270
Advertisement
MindStick DataConverter
Advertise with Us
  
Copyright © 2013MindStick. All Rights Reserved.