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 in any one of the following ways:

  • Choosing Add New Data Source from the Project menu.

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

  • Some bindable controls also provide a Add New Data Source command.

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 connection string to the application configuration file

  • Choose Your Database Objects

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

Note

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 or Entity Data Model (EDM). For more information, see ADO.NET DataSets.

Choose Your Data Connection

Choose an existing connection from the list of connections or create a new one. To create a new connection, click 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.

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. Click 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 schema, 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, click 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

Other Resources

Overview of Data Applications in Visual Studio

Connecting to Data in Visual Studio