Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I have this web.config file and I have added a key value describing the connecting string to a db. I'm wondering whats the easiest way to read the value of the connection string from the web.config file, c# is the language i'm using.

 

<?xml version="1.0" encoding="utf-8" ?>

<configuration>

<!-- define the custom sections used below - do not change -->

<appSettings>

 

<add key="ConnectionString" value="DATA SOURCE=DLNOTC02;User Id=snare;Password=snare"/>

 

</appSettings>

 

<system.web>

<customErrors mode="Off" />

<compilation defaultLanguage="c#" debug="true"/>

<!--<customErrors mode="Off" defaultRedirect="aspx/GlobalError.aspx" />-->

<authentication mode="Windows"/>

<trace enabled="false" requestLimit="10" pageOutput="false" traceMode="SortByTime" localOnly="true"/>

<sessionState mode="Off"/>

<globalization requestEncoding="utf-8" responseEncoding="utf-8" culture="en-GB"/>

 

<webServices>

<protocols>

<add name="HttpSoap"/>

<add name="HttpPost"/>

<add name="HttpGet"/>

<add name="Documentation"/>

</protocols>

</webServices>

 

 

</system.web>

</configuration>

  • *Experts*
Posted

There's more than one way to skin a cat!

string connString = System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"]

"Being grown up isn't half as fun as growing up

These are the best days of our lives"

-The Ataris, In This Diary

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...