Compare Page Revisions
« Older Revision - Back to Page History - Newer Revision »
web.config
app.config
<configuration> <appSettings> <add key="Environment.default" value="Dev"/> <add key="Environment.debugger" value="Dev"/> <add key="Environment.DEVELOPMENTWEBSERVER" value="Dev"/> <add key="Environment.PRODUCTIONWEBSERVER" value="Prod"/> . . . </appSettings> <connectionStrings> <add name="DatabaseName.Dev" connectionString="DevelopmentConnectionString"/> <add name="DatabaseName.Prod" connectionString="ProductionConnectionString"/> </connectionStrings> . . .
Dim csName As String = ConnectionString.GetName("DatabaseName")
string csName = ConnectionString.GetName("DatabaseName");
Imports Microsoft.VisualBasic Public Class ConnectionString Public Shared Function GetName(ByVal dbName As String) As String Dim result As String = "" Dim envKey As String = GetEnvironmentKey() If envKey.Length > 0 Then result = ConfigurationManager.AppSettings(envKey) If result IsNot Nothing And result.Length > 0 Then result = dbName & "." & result End If End If Return result End Function Private Shared Function GetEnvironmentKey() As String Dim result As String = "" If System.Diagnostics.Debugger.IsAttached Then result = "Environment.debugger" Else result = "Environment." + Environment.MachineName.ToUpper() End If If result Is Nothing Then result = "" End If Return result End Function End Class
TODO
ScrewTurn Wiki version 3.0.1.400. Some of the icons created by FamFamFam. Except where noted, all contents Copyright © 1999-2024, Patrick Jasinski.