modify a connection string in the web.config file [modified]
-
Hello VS 2005 I have my connection string in the web.config as followings
appSettings connectionStrings add name="serviceMasterConnectionString" connectionString="Data Source=CF_DEVELOP\realitysql;Initial Catalog=ServiceMaster;User ID=;Password=" connectionStrings
I can read the connection string using the following. but how do i change the connection string.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.config.ConnectionStrings.ConnectionStrings("serviceMasterConnectionString").ConnectionString = "new connection string" config.Save()
Error: Access to the path 'C:\Inetpub\wwwroot\CodeRedIncidents\web.config' 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 -- modified at 5:56 Thursday 12th April, 2007 -
Hello VS 2005 I have my connection string in the web.config as followings
appSettings connectionStrings add name="serviceMasterConnectionString" connectionString="Data Source=CF_DEVELOP\realitysql;Initial Catalog=ServiceMaster;User ID=;Password=" connectionStrings
I can read the connection string using the following. but how do i change the connection string.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.config.ConnectionStrings.ConnectionStrings("serviceMasterConnectionString").ConnectionString = "new connection string" config.Save()
Error: Access to the path 'C:\Inetpub\wwwroot\CodeRedIncidents\web.config' 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 -- modified at 5:56 Thursday 12th April, 2007I don't know wheather you can edit Web.config or not. But I have done this thing using xml file. I have add key connectstring in xml file. And I can chamge it runtime. Hope you like using xml file:|
Regards, Mayank Parmar Senior Software Engineer Amba Tech Gandhinagar, India
-
I don't know wheather you can edit Web.config or not. But I have done this thing using xml file. I have add key connectstring in xml file. And I can chamge it runtime. Hope you like using xml file:|
Regards, Mayank Parmar Senior Software Engineer Amba Tech Gandhinagar, India
Hello, I am sure you can modify the web.config file. After all its only xml. Moreover, how would you change the connection string if you wanted to connect to another database at run-time. I am sure I am not to far off, any extra help would be most grateful, Steve