Well by saving your connection string in a web.config (or app.config) file.
Add something similar:
<configuration>
<connectionStrings>
<clear />
<add name="Target" connectionString="server=MYSERVER; Database=MYDB; Integrated Security=SSPI;" />
</connectionStrings>
</configuration>
Then retrieve it by using
ConfigurationManager
:
ConfigurationManager.ConnectionStrings["Target"].ConnectionString
EDIT:
You also need to reference the
System.Configuration
library in order to make it work.
A simple
textBox1.Text = ConfigurationManager.ConnectionStrings["Target"].ConnectionString;
Will show your connection string ;)
Hope it helps
Cheers!