Source Code: Create Data Table And Columns With DataSet Designer Visual Basic 2005
This article provides the steps to manually create a stand-alone DataTable in a DataSet with the Visual Studio 2005 DataSet Designer. This article is a precursor to an article that will explain how to use a DataSet and an XML file to implement a simple database and how to perform CRUD (Create, Retrieve, Update, and Delete) operations on the data stored in the XML file.
DataSets are made up of one or more DataTables.
You can add a DataTable to a DataSet by right-clicking the surface of the DataSet Designer and selecting Add -> DataTable.
You can add the individual DataColumns that make up a DataTable by right-clicking a DataTable in the DataSet designer and selecting Add -> Column.
The steps provided below demonstrate how to create a stand-alone DataTable named 'Customer' that contains eight DataColumns:

Create a DataSet and Add a New Stand-Alone DataTable.
-
Start a new Visual Studio 2005 Visual Basic Windows Forms project.
-
Add a DataSet named 'MyDataSet' to the Visual Studio project.

-
The Dataset Designer will automatically open.

-
Right click the surface of the Dataset Designer and select Add -> DataTable.

-
A new DataTable will be added to the DataSet Designer.

-
Click 'DataTable1' in the DataTable title bar and change the name of the DataTable to 'Customer'

Add Columns to the 'Customer' DataTable.
-
Right-click the icon in the DataTable title bar and select Add -> Column

- A column will be added to the DataTable.

-
Replace the default column name, by selecting the column name in the data table and editing the text to read 'customer_id'.

- Click to the left of the 'customer_id' column to select it. View the Visual Studio Properties panel. The 'customer_id' column will be provide a unique identity number for each customer added to the Customer DataTable. Set the 'customer_id' column's AllowDBNull property value to False. Set the 'customer_id' column's AutoIncrement property value to True. The column's DataType property value will be automatically changed to System.Int.32.

- Add the additional columns shown below to complete the Customer table. Accept the default properties for the additional columns you add.

Click the link above to download Visual Basic source code in a Visual Studio 2005 solution which includes a DataTable created in the DataSet designer. This solution does not perform any operations.
Mike McIntyre