Move connection string from actual page to web.config.

  • Thread starter Thread starter rehiaa
  • Start date Start date
R

rehiaa

How do I move my connction string from each page and instead refer to it
from the web.config file?
In Web.Config I have

<appSettings>

<add key="ConnectionString"
value="server=Server;database=DB;uid=name;pwd=p"/>

</appSettings>

Inmy webform I have

private void InitializeComponent()

{

this.connection.ConnectionString = "workstation id=PC...



regards

Reihaa
 
Hi,

Use
System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"];
to get the key ConnectionString.
 
Back
Top