|
-
Oct 17th, 2002, 10:46 AM
#1
Thread Starter
New Member
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
-
Oct 17th, 2002, 11:35 AM
#2
Junior Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|