467,169 Members | 986 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,169 developers. It's quick & easy.

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
  • viewed: 866
Share:
1 Reply
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

131 posts views Thread by Peter Foti | last post: by
2 posts views Thread by Joe Bloggs | last post: by
1 post views Thread by MichaelG | last post: by
4 posts views Thread by Ned Balzer | last post: by
13 posts views Thread by G | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.