Move connection string from actual page to web.config.

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
 
P

Peter Jausovec

Hi,

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top