View previous topic :: View next topic |
Author |
Message |
Tunes
Joined: 18 Oct 2004 Posts: 2
|
Posted: Mon Oct 18, 2004 7:46 pm Post subject: ASP.NET Application object? |
|
|
Im new to ASP.NET, but I have some experience with ASP.
In ASP I keep my SQL connection strings in Application object and I can use them everywhere in my application like this:
Application("strConnection")
Can I do the same in ASP.NET, or is there a better way to do that? |
|
Back to top |
|
|
administrator Site Admin
Joined: 01 Oct 2004 Posts: 183
|
Posted: Mon Oct 18, 2004 9:49 pm Post subject: |
|
|
Hi,
With ASP.NET you can keep your configuration settings in your web.config file like this:
<configuration>
....
....
<appSettings>
<add key="strConnection" value="Your_Connection_String_Here" />
</appSettings>
....
....
</configuration>
You can add more key/value pairs by adding <add> elements in the web.config. To read the value in your code, do the following:
strConn = System.Configuration.ConfigurationSettings.AppSettings("strConnection")
Cheers, _________________ Peter
ASP & ASP.NET Articles and Tutorials |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2002 phpBB Group
|