The document is archived and information here might be outdated
Walkthrough: Creating a DataTable in the Dataset Designer
This walkthrough explains how to create a
(without a TableAdapter) using the DataTable Dataset Designer. For information on creating data tables that include TableAdapters, see . How to: Create TableAdapters
Tasks illustrated in this walkthrough include:
Creating a new Windows Application project
Adding a new dataset to the application
Adding a new data table to the dataset
Adding columns to the data table
Setting the primary key for the table
To create a new Windows Application project
File menu, create a new project.
Choose a programming language in the
Project Types pane.
Windows Application in the Templates pane.
Name the project
DataTableWalkthrough, and then click OK.
Visual Studio adds the project to
Solution Explorer and displays Form1 in the designer. To add a new dataset item to the project
Project menu, click Add New Item.
appears. Add New Item Dialog Box
Templates box, select DataSet.
Visual Studio will add a file called
DataSet1.xsd to the project and open it in the Dataset Designer. To add a new data table to the dataset
DataTable from the DataSet tab of the Toolbox onto the Dataset Designer.
A table named
DataTable1 is added to the dataset.
Click the title bar of
DataTable1 and rename it Music. To add columns to the data table
Music table. Point to Add, and then click Column.
Name the column
Properties window, set the property to DataType . System.Int16
Repeat this process and add the following columns:
All data tables should have a primary key. A primary key uniquely identifies a specific record in a data table.
To set the primary key of the data table
SongID column, and then click Set Primary Key.
A key icon appears next to the
SongID column. To save the DataTableWalkthrough project
Now that you have created the table, you might want to perform one of the following actions: