Hello
VS 2005
I have my connection string in the web.config as I am developing a ASP.NET website the code as followings
I can read the connection string using the following. but how do i change the connection string.
I tried the following and got an error message.
Error:
Access to the path 'C:\Inetpub\ is denied.
I would like to change the connection string at run-time and save it.
Does anyone have any code examples.
Many thanks,
Steve
VS 2005
I have my connection string in the web.config as I am developing a ASP.NET website the code as followings
Code:
appSettings
connectionStrings
add name="serviceMasterConnectionString" connectionString="Data Source=CF_DEVELOP\realitysql;Initial Catalog=ServiceMaster;User ID=assword="
connectionStrings
I can read the connection string using the following. but how do i change the connection string.
Code:
imports system.web.configuration
imports system.configuration
Dim cnnString As String
cnnString = WebConfigurationManager.ConnectionStrings("serviceMasterConnectionString").ConnectionString()
cnn.ConnectionString = cnnString
I tried the following and got an error message.
Code:
config.ConnectionStrings.ConnectionStrings("serviceMasterConnectionString").ConnectionString = "new connection string"
config.Save()
Error:
Access to the path 'C:\Inetpub\ is denied.
I would like to change the connection string at run-time and save it.
Does anyone have any code examples.
Many thanks,
Steve