Hello,
VS 2005 SQL 2005
I would like to change the connection string dynamcially during program run-time. But get the code to work. There is no run-time errors and the code compiles ok. However, the code does not let me get the connection string, and I would like to update the connection string at run-time.
This is my code in the web.config file.
The code in my website that is used to retrieve the website is as follows:
incidents is the folder that contains the web.config file. That has a virtual path in the IIS.
Can anyone correct if I have done anything wrong in the code above,
Many thanks in advance,
Steve
VS 2005 SQL 2005
I would like to change the connection string dynamcially during program run-time. But get the code to work. There is no run-time errors and the code compiles ok. However, the code does not let me get the connection string, and I would like to update the connection string at run-time.
This is my code in the web.config file.
Code:
<connectionStrings>
<add name="ServiceMasterConnectionString"
connectionString ="data source=dev01; initial catalog = serviceMaster; user id=; pwd="
providerName="System.Data.SqlClient"/>
</connectionStrings>
The code in my website that is used to retrieve the website is as follows:
Code:
imports system.configuration.configuration
Dim rootWebConfig As System.Configuration.Configuration
rootWebConfig = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("/Incidents/")
Dim connString As System.Configuration.ConnectionStringSettings
connString = rootWebConfig.ConnectionStrings.ConnectionStrings("ServiceMasterConnectionString")
incidents is the folder that contains the web.config file. That has a virtual path in the IIS.
Can anyone correct if I have done anything wrong in the code above,
Many thanks in advance,
Steve