Dela via


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, Web services, or objects, and can be bound to controls that display data on forms. For more information, see Data Sources Overview.

After you run the wizard, the data source is available in the Data Sources window for dragging onto forms in Windows applications. For more information, see Displaying Data on Forms in Windows Applications.

Starting in Visual Studio 2008 SP1, you can configure data synchronization from the Data Source Configuration Wizard. For more information, see Walkthrough: Creating an Occasionally Connected Application by Using the Data Source Configuration Wizard.

In addition, support for the change tracking feature in SQL Server 2008 has been added for Visual Studio 2008 SP1. You can enable SQL Server 2008 change tracking when you configure synchronization from the Data Source Configuration Wizard. For more information, see How to: Configure Data Synchronization to Use SQL Server Change Tracking.

Running the Wizard

You can run the wizard in any one of the following ways:

  • Choosing Add New Data Source from the Data menu.

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

  • Choosing Add New Data Source from the DataSource property of bindable Windows Forms controls.

Depending on the selected data source type (database, Web service, or object) the wizard will begin on any one of several pages in the wizard. For information about a specific page, select from the following list:

  • Choose a Data Source Type

  • Choose Your Data Connection

  • Save connection string to the application configuration file

  • Choose Your Database Objects

  • Choose Tables to Cache (Visual Studio 2008 SP1)

  • Add Web Reference

  • Select an Object you wish to bind to

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, Web services, and objects. The result of running the wizard is determined by the type of data source selected.

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

Web service

Enables your application to connect and work with the data and methods of a Web service.

Because Web services can return many different types of objects, the resulting data source is determined by the objects returned from the Web 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.

Choose Your Data Connection

Choose an existing connection from the list of connections or click New Connection to open the Add/Modify Connection Dialog Box (General) and create a connection to the database.

Upon completion of the Connection Properties dialog box, the Connection Details area displays read-only information about the selected provider and the connection string.

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

Saving connection strings in the application configuration file simplifies the process of maintaining your application if the database connection changes. In the event of a change in the database connection, you can modify the connection string in the application configuration file instead of editing the source code and having to recompile your application. For information about editing a connection string in the application configuration file, see How to: Edit a Connection String.

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 the objects from the database to bring into the application.

Select Enable local database caching to store (cache) data in a local database on the client. Select all the database objects that you want in your dataset, and you are given the option to select which tables to actually cache locally on the next page of the wizard (the Choose Tables to Cache page). For more information about local database caching, see Occasionally Connected Applications Overview.

Provide a name for the dataset in the Dataset name box.

Tip

You can resize the window if you need to.

Choose Tables to Cache (Visual Studio 2008 SP1)

This page appears only if you selected Enable local database caching on the Choose Your Database Objects page.

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 2008 change tracking to use the change tracking features incorporated into SQL Server 2008.

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

Add Web Reference

Completing the Add Web Reference page of the wizard adds a reference to the Web service in your project and populates the Data Sources window with objects returned from the Web service. The data source created from the Web service contains the items returned from the Web service. For example, if the Web service returns a typed dataset, the data source created is the dataset, whereas if the Web service returns a type, the data source is the type returned. For more information, see Add Web Reference Dialog Box.

Note

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

Select an Object you wish to bind to

Select the object to bind to from the tree view. The tree view only displays objects currently in your application. To bind an object external to your application, you must first add a reference from your application to the external object. To add references to external assemblies, click Add Reference on the Project menu, and then select the assembly you want in the Add Reference Dialog Box. After adding the reference, navigate in the tree view to the type you want and click Next.

Note

If the object you want does not appear in the wizard, build the project that contains your object and restart the wizard.

See Also

Tasks

How to: Create TableAdapters

How to: Create TableAdapter Queries

Concepts

TableAdapter Overview

Occasionally Connected Applications Overview

Other Resources

Getting Started with Data Access

Connecting to Data in Visual Studio

Preparing Your Application to Receive Data

Fetching Data into Your Application

Displaying Data on Forms in Windows Applications

Editing Data in Your Application

Validating Data

Saving Data