473,387 Members | 1,535 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Best Practice for using a string across the app??

I need to have a string available per page, i.e. the SQL Connection String. What's the best way of doing this? Right now I have it loaded into a session variable, but I think I should do something with global.asax??

Thanks!

--
David Lozzi
Web Applications/Network Specialist
Delphi Technology Solutions, Inc.
dlozzi(remove-this)@delphi-ts.com
Nov 19 '05 #1
1 974
the best thing to do is to put it in your web.config. It can then be accessed via ConfigurationSettings.AppSettings("connectionStrin g"). Even better would be to build a wrapper utility for this:

Public NotInheritable Class DatabaseUtility
Private Sub New()
End Sub

Public Shared ReadOnly Property ConnectionString() As String
Get
Return ConfigurationSettings.AppSettings("connectionStrin g")
End Get
End Property

End Class

it can then be accessed via DatabaseUtility.ConnectionString

Session is a bad place for it..since htere'a session by user, but this is a global thing.

--
MY ASP.Net tutorials
http://www.openmymind.net/
"David Lozzi" <dlozzi(remove-this)@delphi-ts.com> wrote in message news:OU***************@TK2MSFTNGP11.phx.gbl...
I need to have a string available per page, i.e. the SQL Connection String. What's the best way of doing this? Right now I have it loaded into a session variable, but I think I should do something with global.asax??

Thanks!

--
David Lozzi
Web Applications/Network Specialist
Delphi Technology Solutions, Inc.
dlozzi(remove-this)@delphi-ts.com
Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

131
by: Peter Foti | last post by:
Simple question... which is better to use for defining font sizes and why? px and em seem to be the leading candidates. I know what the general answer is going to be, but I'm hoping to ultimately...
136
by: Matt Kruse | last post by:
http://www.JavascriptToolbox.com/bestpractices/ I started writing this up as a guide for some people who were looking for general tips on how to do things the 'right way' with Javascript. Their...
2
by: Joe Bloggs | last post by:
I have a general question on best practice regarding data access. I have the code below, a static method defined in a class that I use in a data layer dll. The method takes a string as its...
1
by: JohnH. | last post by:
Hi, Is there a better (best practice) way to do this? I have developed a large set of ASP.NET applications in C#. Like most applications I have a set of utility pages that can be called by...
17
by: | last post by:
I have an app that retrieves data from an Access database. At the moment I have the SQL string as a Const in my app. I understand this is not best practice. I don't want the user to have access to...
1
by: MichaelG | last post by:
I have a web service that talks to SQL Server 2005. At present the WS uses an SQL Server login and password to connect. Is this best practice or should I be running the WS under a domain account...
4
by: Ned Balzer | last post by:
Hi all, I am pretty new to asp.net; I've done lots of classic asp, but am just beginning to get my mind wrapped around .net. What I'd like to do is include some code that tests if a user is...
13
by: G | last post by:
Hello, Looking for opinions on a fairly simple task, new to ASP.net (C#) and want to make sure I do this as efficiently as possible. I have a web based form, and I need to run some SQL before...
9
by: =?Utf-8?B?QW1tZXI=?= | last post by:
I've read many incomplete opinions about the "Best Practice" for securely accessing SQL but what I really need to find the "Best Practice" that fits my applications needs. Currently (alpha...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.