Results 1 to 2 of 2

Thread: change the loaction of the database without re-programming the web-application!?!

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2002
    Location
    England
    Posts
    9

    Question change the loaction of the database without re-programming the web-application!?!

    how do i allow the the database server (which may be on a different server to the web server) be able to change without re-programming of the web application?

    at the moment i have a global.asax:


    Code:
    <%@ Import Namespace="System.Net" %>
    <script runat="server">
    Sub Session_OnStart()
    Session("conClasf") = _
    "Data Source=localhost;Integrated Security=SSPI;" & _
    "Initial Catalog=Database"
    Try
    Session("hostname") = _
    Dns.GetHostByAddress(Request.UserHostAddress).HostName
    Catch ex As Exception
    Session("hostname") = Request.UserHostAddress
    End Try
    End Sub
    </script>


    ?
    bernie

  2. #2
    Junior Member
    Join Date
    May 2002
    Posts
    20
    If you mean to simply point your web with a different connection string... Let your web.config hold your connection string instead.

    Open your web.config file and make the following change:

    <configuration>
    <appSettings>
    <add key="connString" value="Your connection string" />
    </appSettings>

    ...

    Now you have an application wide setting named connString that holds your connection string. You can access it from anywhere in you site like so:

    ConfigurationSettings.AppSettings("connString")

    If you need to change database locations... just open the web.config in notepad and modify the value of connString and save it... and everything is redirected instantly.

    Is that what you asking?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width