Edit1Property
Edit1Value
Edit1Visible
Edit2Property
Edit2Value
Edit2Visible
Edit3Label
Edit3Property
Edit3Value
Edit3Visible
CustomActionData
Install
Dim site As String = Me.Context.Parameters.Item("site") Dim appName As String = Me.Context.Parameters.Item("vdir") Dim sqlServerInstance As String = Me.Context.Parameters.Item("sqlsvr") Dim siteNum as Integer = Integer.Parse(site.Substring(site.LastIndexOf("/") + 1)) - 1 Dim mySite As Microsoft.Web.Administration.Site = mgr.Sites(siteNum) Dim myApp As Microsoft.Web.Administration.Application = mySite.Applications("/" & appName) Dim mgr As ServerManager = New ServerManager() Dim rootPath As String = myApp.VirtualDirectories("/").PhysicalPath TweakConnectionStringDataSource(rootPath, "Local", sqlServerInstance)
Private Shared Sub TweakConnectionStringDataSource(rootPath As String, connectionStringName As String, newDataSource As String) Dim configFile As String = Path.Combine(rootPath, "web.config") Dim doc As XmlDocument = New XmlDocument() doc.Load(configFile) Dim xPath As String = "/configuration/connectionStrings/add[@name='" & connectionStringName & "']" Dim node As XmlNode = doc.SelectSingleNode(xPath) Dim attr As XmlAttribute = node.Attributes("connectionString") Dim conn = New SqlConnectionStringBuilder(attr.Value) ' We do this tweak because, for some reason, when the user specified ".\SQLEXPRESS" (for example) ' it comes in here as ".\\SQLEXPRESS". newDataSource = newDataSource.Replace("\\", "\") conn.DataSource = newDataSource attr.Value = conn.ConnectionString Dim newConfigFile = configFile ' Path.Combine(rootPath, "web2.config") ' This is for testing doc.Save(newConfigFile) End Sub