Best Practice for using a string across the app??

Discussion in 'ASP .Net' started by David Lozzi, Dec 6, 2004.

  1. David Lozzi

    David Lozzi Guest

    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
     
    David Lozzi, Dec 6, 2004
    #1
    1. Advertising

  2. David Lozzi

    Karl Seguin Guest

    the best thing to do is to put it in your web.config. It can then be accessed via ConfigurationSettings.AppSettings("connectionString"). 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("connectionString")
    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:OUMuUL%...
    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
     
    Karl Seguin, Dec 6, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Andy Fish
    Replies:
    1
    Views:
    413
  2. Jheitmuller
    Replies:
    1
    Views:
    473
  3. Nemisis
    Replies:
    1
    Views:
    518
    Mark Rae
    Apr 4, 2007
  4. yermej
    Replies:
    9
    Views:
    153
    Richard Conroy
    Jul 17, 2010
  5. Matthias S.
    Replies:
    5
    Views:
    294
    Matthias S.
    Feb 9, 2011
Loading...

Share This Page