read and write to the web.config file
hello all,
i have a web application that i want users to be able to change the name of the server and database from a web page.
i have got this to work using this...
Code:
Public Sub SetValue(ByVal key As String, ByVal value As Object)
Dim ds As New DataSet()
ds.ReadXml(System.Web.HttpRuntime.AppDomainAppPath & "web.config")
Dim dr() As DataRow = ds.Tables("add").Select(String.Concat("key='", key, "'"))
dr(0).Item("value") = value
ds.WriteXml(System.Web.HttpRuntime.AppDomainAppPath & "web.config")
ds.Clear()
End Sub
called by this:
Code:
Dim aw As New AppSettinsWriter()
aw.SetValue("ConnectionPCSRead", "data source=" & txtServer.Text & ";initial catalog=" & lblDatabase.Text & ";persist security info=False;user id=sa;password=;packet size=4096")
but i need to display the server and database apon load of the web page, so the user can see what they are editing!
at the mo it's just empty text boxes.
I need to display the "data source" in the server box,
and to display the "initial catalog" in the database box.
please could you help,
thanks,
Tom.