Data Source Configuration Wizard

The Data Source Configuration Wizard creates and edits data sources in your application. These data sources can be made from databases, services, or objects. They can also be bound to controls that display data. For more information, see Data Sources Overview.

After you run the wizard, the data source is available in the Data Sources window. You can create data-bound controls by dragging the data source to a design surface. For more information, see Binding Controls to Data in Visual Studio.

Running the Wizard

You can run the wizard by doing one of the following:

  • Choosing Add New Data Source from the Data menu.

  • Choosing Add New Data Source from the Data Sources Window.

  • Selecting an Add New Data Source command from those bindable controls that provide them.

The wizard will begin by opening any one of several pages. For information about a specific page, select from the following list:

  • Choose a Data Source Type

  • Choose a Database Model

  • Choose Your Data Connection

  • Save the Connection String to the Application Configuration File

  • Choose Your Database Objects

  • Choose Tables to Cache

  • Add Service Reference

  • Select the Data Objects

Choose a Data Source Type

Select the type of data source to create from the available options listed on the Choose a Data Source Type page. Currently supported data source types include databases, services, and objects. The type of data source that you select determines which data objects are created in your project.

The following table shows the results of selecting each type.

Data source type

Description

Result in project

Database

Enables your application to connect and change data in database products, such as Microsoft SQL Server.

A typed dataset (.xsd file).

Service

Enables your application to connect and work with the data and methods of a Windows Communication Foundation (WCF) service, a WCF Data Services, or a web service.

Because services can return many different types of objects, the resulting data source is determined by the objects returned from the service.

Object

Enables your application to work with data in existing objects.

If the object is not located in the project, you must add a reference to the selected object for it to appear in the wizard.

SharePoint

Enables your application to work with data from a SharePoint site.

SharePoint data sources connect through services so the resulting data source is determined by the SharePoint objects returned from the service.

NoteNote
Creating SharePoint data sources is supported in SharePoint 2010 only.

Choose a Database Model

When you add a database data source from the Choose a Data Source Type page, the wizard displays the Choose a Database Model page.

Choose to generate a dataset if you want to connect directly to your relational storage schema. Choose Entity Data Model (EDM) if you instead want to program against a conceptual application model. For more information, see ADO.NET DataSets, and ADO.NET Entity Framework.

Choose Your Data Connection

Choose an existing connection from the list of connections or create a new one. To create a new connection, choose New Connection to open the Add/Modify Connection Dialog Box (General).

After the values in the Connection Properties dialog box are set, the Connection Details area displays read-only information about the selected provider and the connection string.

Save the Connection String to the Application Configuration file

Choose Yes, save the connection as to store the connection string in the application configuration file. Type a name for the connection or use the provided default name.

By saving connection strings in the application configuration file, you can simplify the process of maintaining your application. If the database connection changes, you can modify the connection string in the application configuration file instead of editing the source code and recompiling your application. For information about how to edit a connection string in the application configuration file, see How to: Save and Edit Connection Strings.

Security noteSecurity Note

Information is stored in the application configuration file as plain text. To reduce the risk of unauthorized access to sensitive information, you may want to encrypt your data. For more information, see Encrypting and Decrypting Data.

Choose Your Database Objects

From the available objects displayed in the tree view, select objects from the database to bring into the application. Provide a name for the dataset in the Dataset name box.

If you want to store (cache) data in a local database on the client, select Enable local database caching and select all the database objects that you want in your dataset. The next page of the wizard—the Choose Tables to Cache page—gives you the option of specifying which tables you will cache locally. For more information about local database caching, see Occasionally Connected Applications Overview. For a walkthrough that demonstrates how to use local database caching, see Walkthrough: Creating an Occasionally Connected Application by Using the Data Source Configuration Wizard.

Choose Tables to Cache

The wizard displays this page if you select Enable local database caching on the Choose Your Database Objects page.

Note

Enable local database caching is only available when Microsoft Synchronization Services v2.0 is installed. For more information, see Occasionally Connected Applications (Local Database Caching).

Select the table or tables that you want to cache locally on the client, and select the synchronization mode for each table.

When you connect to a SQL Server 2008 database, you can select Use SQL Server change tracking to use the change tracking features incorporated into SQL Server 2008. For more information, see How to: Configure Data Synchronization to Use SQL Server Change Tracking.

For more information about incorporating a local database cache into your application, see Occasionally Connected Applications Overview.

Add Service Reference

If you add a service data source from the Choose a Data Source Type page, the wizard displays the Add Service Reference page.

Use the Add Service Reference Dialog Box dialog box to add a reference to a service. After you save the dialog box settings, you will return to the Add Service Reference page in the Data Source Configuration Wizard. Choose Finish to complete the wizard.

After you complete the wizard, Visual Studio adds a reference to the service in your project. Visual Studio also populates the Data Sources window with objects that are returned by the service. For example, if the service returns a typed dataset, the data source created is the dataset, whereas if the service returns a type, the data source is the type returned.

Note

The items that appear in the Data Sources window are dependent on the information that the service returns. Some services might not provide enough information for the Data Source Configuration Wizard to create bindable objects. For example, if the service returns an untyped dataset, no items will appear in the Data Sources window upon completion of the wizard. This happens because untyped datasets do not provide schemas, so the wizard has insufficient information to create the data source.

Select the Data Objects

If you add an object data source on the Choose a Data Source Type page, the wizard displays the Select the Data Objects page.

This page contains a tree view that displays the objects in your project and in assemblies and projects referenced by your project. Select the check box next to each object you want to bind to. After you select all the objects you want to bind to, click Next.

If the object you want to bind to does not appear in the tree view, perform one of the following steps:

  • If the object is defined in your project, rebuild your project and then restart the Data Source Configuration Wizard.

  • If the object is defined in an external assembly or project, choose Add Reference and use the Add Reference Dialog Box to add a reference to the assembly or project. After adding the reference, the assembly or project appears in the tree view.

By default, the tree view does not display assemblies that are part of the .NET Framework or Visual Studio. If you want to bind to objects in these assemblies, clear the Hide system assemblies check box.

See Also

Tasks

How to: Create TableAdapters

How to: Create TableAdapter Queries

Concepts

TableAdapter Overview

Preparing Your Application to Receive Data

Fetching Data into Your Application

Binding Controls to Data in Visual Studio

Editing Data in Your Application

Validating Data

Saving Data

Occasionally Connected Applications Overview

Other Resources

Overview of Data Applications in Visual Studio

Connecting to Data in Visual Studio

Change History

Date

History

Reason

August 2011

Add information to help users decide between a dataset and an Entity Data Model.

Customer feedback.