p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   ASP.NET 1.0 and 1.1 Professional (http://p2p.wrox.com/forumdisplay.php?f=57)
-   -   connection string (http://p2p.wrox.com/showthread.php?t=36861)

nalla January 6th, 2006 04:58 AM

connection string
 


Hi,

(1) What's the best place to store connection string in a ASP.Net project?
(2) How can I access it in asp pages?
(3) What's the solution for global variables in a ASP.Net project?

Thanx.





planoie January 6th, 2006 09:47 AM

1. Most recommend you put the connection string in the web.config file:

<appSettings file="user.config">
  <add key="CONNSTRING" value="<your connection string here>" />
</appSettings>

2. Retrieve it using System.Configuration.ConfigurationSettings:
C#: System.Configuration.ConfigurationSettings.AppSett ings["CONNSTRING"]
VB: System.Configuration.ConfigurationSettings.AppSett ings("CONNSTRING")

3. Avoid using them. A properly designed application shouldn't need them. What would you intend to use them for? There may be better solutions depending on what you want to do.

-Peter

nalla January 23rd, 2006 04:03 AM


Hi peter,

Thank you very much.


nalaka hewage


All times are GMT -4. The time now is 02:05 PM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.