Share via


Walkthrough: Creating a Dataset with the Dataset Designer

In this walkthrough you will create a dataset using the Dataset Designer. It will take you through the process of creating a new project and adding a new DataSet item to it. You will learn how to create tables based on tables in a database without using a wizard.

Tasks illustrated in this walkthrough include:

  • Creating a new Windows Application project.

  • Adding an empty DataSet item to the project.

  • Creating and configuring a data source in your application by building a dataset with the Dataset Designer.

  • Creating a connection to the Northwind database in Server Explorer.

  • Creating tables with TableAdapters in the dataset based on tables in the database.

Note

The dialog boxes and menu commands you see might differ from those described in Help depending on your active settings or edition. To change your settings, choose Import and Export Settings on the Tools menu. For more information, see Visual Studio Settings.

Prerequisites

In order to complete this walkthrough, you need:

Creating a New Windows Application Project

To create a new Windows Application project

  1. From the File menu, create a new project.

  2. Choose a programming language in the Project Types pane.

  3. Click Windows Application in the Templates pane.

  4. Name the project DatasetDesignerWalkthrough, and then click OK.

    Visual Studio will add the project to Solution Explorer and display a new form in the designer.

Adding a New Dataset to the Application

To add a new dataset item to the project

  1. On the Project menu, click Add New Item.

    The Add New Item dialog box appears.

  2. In the Templates box of the Add New Item dialog box, click DataSet.

  3. Name the Dataset NorthwindDataset, and then click Add.

    Visual Studio will add a file called NorthwindDataset.xsd to the project and open it in the Dataset Designer.

Creating a Data Connection in Server Explorer

To create a connection to the Northwind database

  1. On the View menu, click Server Explorer.

  2. In Server Explorer, click the Connect to Database button.

  3. Create a connection to the Northwind sample database.

    Note

       You can connect to the SQL Server or Access version of Northwind for this walkthrough.

    For information on creating a connection to SQL Server, see How to: Create Connections to SQL Server Databases.

    For information on creating a connection to Access, see How to: Create Connections to Access Databases.

Creating the Tables in the Dataset

This section will explain how to add tables to the dataset.

To create the Customers table

  1. Expand the data connection you created in Server Explorer, and then expand the Tables node.

  2. Drag the Customers table from Server Explorer onto the Dataset Designer.

    A Customers data table and CustomersTableAdapter are added to the dataset.

To create the Orders table

  • Drag the Orders table from Server Explorer onto the Dataset Designer.

    An Orders data table, OrdersTableAdapter, and data relation between the Customers and Orders tables are added to the dataset.

To create the OrderDetails table

  • Drag the Order Details table from Server Explorer onto the Dataset Designer.

    An Order Details data table, OrderDetailsTableAdapter, and a data relation between the Orders and Order Details tables are added to the dataset.

Next Steps

To add functionality to your application

See Also

Concepts

What's New in Data

Displaying Data Overview

Other Resources

Data Walkthroughs

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