Changing Database Connection Settings

The Web.config file created for your application 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 to 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 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=" Provider=SQLOLEDB;
          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.

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”.

See Also

Deploying Applications to a Production Server

Configuring Database Authentication for Microsoft SQL Server Applications