Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Professional For advanced ASP.NET 1.x coders. Beginning-level questions will be redirected to other forums. NOT for "classic" ASP 3 or the newer ASP.NET 2.0 and 3.5
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 6th, 2006, 04:58 AM
Friend of Wrox
 
Join Date: Dec 2005
Posts: 132
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to nalla Send a message via Yahoo to nalla
Default 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.




__________________
nalaka hewage
http://nalakahewage.blogspot.com
 
Old January 6th, 2006, 09:47 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

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
 
Old January 23rd, 2006, 04:03 AM
Friend of Wrox
 
Join Date: Dec 2005
Posts: 132
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to nalla Send a message via Yahoo to nalla
Default


Hi peter,

Thank you very much.


nalaka hewage





Similar Threads
Thread Thread Starter Forum Replies Last Post
Connection string MunishBhatia ASP.NET 2.0 Professional 4 May 16th, 2007 05:50 AM
Connection String jmss66 Oracle 4 August 8th, 2006 03:19 AM
Connection String slgknjn VB Databases Basics 2 February 26th, 2005 03:14 AM
Connection String fs22 Classic ASP Databases 3 August 30th, 2004 01:25 AM
Connection String Help. diamond2165 BOOK: ASP.NET Website Programming Problem-Design-Solution 1 November 7th, 2003 06:09 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.