Changing Database Connection Settings

Your application’s Web.config file contains the database connection settings for accessing the databases used by your application.  These settings allow your application to log into the respective databases.  Most likely, you selected databases on your local machine or in a test environment when building and testing your application.  Now that you are moving the application into production, you will need to change these settings to point to the production database system(s).

Microsoft Access

Edit the database-related keys in your application’s Web.config file to point to a different database.  You should see an entry like this:

<add key="DatabaseNorthwind.mdb1"

     value="Provider=Microsoft.Jet.OLEDB.4.0;
          Data Source=C:\IronSpeed\TestAccessDB\TestTypes.mdb;
          Jet OLEDB:Database Locking Mode=1;
          Mode=Share Deny None"

/>

Make sure the Data Source is the file name of your production database.  Do not change the key name (e.g., "DatabaseNorthwind.mdb1"); instead, alter the value as necessary, such as changing the Data Source.

Details on these connection parameters are in “Web.Config Configuration File”.

Microsoft SQL Server

Edit the database-related keys in your application’s Web.config file to point to a different database.  You should see an entry like this:

<add key="DatabaseNorthwind1"

     value="Data Source=localhost;

          Database=Northwind;

          Trusted_Connection=no;

          User Id=sa;

          Password=sasa"

/>

Do not change the key name (e.g., "DatabaseNorthwind1"); instead, alter the value as necessary, such as changing the Data Source.

MySQL

Edit the database-related keys in your application’s Web.config file to point to a different database.  You should see an entry like this:

<add key="DatabaseSakila1"

     value="Data Source=myserver;

          Port=3306;

          Database=Sakila;

          User Id=sa;

          Password=sasa"

/>

Do not change the key name (e.g., "DatabaseSakila1"); instead, alter the value as necessary, such as changing the Data Source.

Oracle

Edit the database-related keys in your application’s Web.config file to point to a different database.  You should see an entry like this:

<add key="DatabaseSCOTT1"

     value="Data Source=ORCL_MYHOST;

          Database=SCOTT;

          User Id=scott;

          Password=tiger"

/>

Do not change the key name (e.g., " DatabaseSCOTT1"); instead, alter the value as necessary, such as changing the Data Source.

See Also

Deploying Applications with the Deployment Wizard

Manually Deploying an Application to a Production Server

Deploying to Application Hosting Service Providers

Changing Database Connection Settings

Adding Your Application to the Windows Registry

Starting Your Session State Service

Configuring Database Authentication for Microsoft SQL Server Applications