• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 533
  • Last Modified:

retrieve value from Web.Config

Using C#, from a WEB.CONFIG, how do I retrieve the value "Server=XYZ;Initial Catalog=ABC;User=MyName;password=pswd;" Here's the WebConfig

<?xml version="1.0"?>
     <configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
     <connectionStrings>
          <add name="MyCustKey" connectionString="Server=XYZ;Initial Catalog=ABC;User=MyName;password=pswd;" providerName="System.Data.SqlClient"/>
     </connectionStrings>
</configuration>

0
volking
Asked:
volking
1 Solution
 
bele04Commented:
you'd do something like this in your code:
string strConnString = ConfigurationManager.ConnectionStrings["MyCustKey"].ConnectionString;
0
 
YZlatCommented:
are you using 1.1 or 2.0?
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now