RAD Studio for Microsoft .NET |  |

Creating Table Mappings
See Also
Collapse All

Using the TableMappings property, you can map columns between a data source and an in-memory dataset. This allows you to use different, often more descriptive names for your dataset columns. You can also map a column in a database table to a column in the dataset different from that which is selected by default. The TableMappings property also allows you to create a dataset that contains fewer or more columns than those retrieved from the database schema.

To create a table mapping

1. Create an application.
2. Add and configure database components.
3. Set the table mappings in the TableMappings dialog.
   Note: This procedure assumes you are using BDP.NET database components.

To create an application

1. Choose FileNewWindows Forms Application for either Delphi for .NET or C#.
2. Click the Data Explorer tab to display your data sources.
3. Expand the list and locate a live data source.
4. Drag-and-drop a table name onto your Windows Form to add a data source to your application. You should see two objects in the Component Tray: a BdpDataAdapter and a BdpConnection.

For more information about how to create database applications, refer to the additional ADO.NET and database topics in this Help system.
To configure the database components

1. Select the BdpDataAdapter icon in the Component Tray.
2. Click the Configure Data Adapter designer verb to open the Data Adapter Configuration dialog.
3. Select the DataSet tab.
4. Click the New DataSet radio button.
5. Click OK. This creates a new dataset and displays an icon for it in the Component Tray.

To set table mappings

1. Select the BdpDataAdapter icon in the Component Tray.
2. Double-click the Collections field for the TableMappings property in the Object Inspector. This displays the TableMappings dialog.
3. If you want to use an existing dataset as a model for the columns, check the Use a dataset to suggest table and column names check box. This provides you with a list of column names from an existing dataset based on the schema of that dataset. The column names are not linked to anything when you use this process.
4. If you checked the Use a dataset to suggest table and column names check box, you can choose the dataset from the DataSet drop down list.
5. Select the source table from the Source table drop down list. If there is more than one table in the data source, their names appear in the drop down list.
6. If you chose to use a dataset to suggest table and column names, and that dataset contains more than one table, you can select the table you want to use from the Dataset table drop down list. The column names from the source table and from the dataset should appear in the Column mappings grid. As they are displayed by default, they represent the mapping from source to dataset; in other words, the data adapter reads data from each column named on the left side of the grid and stores the data in the dataset column named in the corresponding field on the right side of the grid. You can change the names on either side by typing new names or by selecting different tables. This allows you to store queried data into different dataset columns than the ones created in the dataset by default.
7. If you want to modify a mapping, type a new name in the Dataset table column next to the target Source table column. This results in the data from the Source table column being stored in the new dataset column.
   Note: If you want to reset the column names so that the dataset columns match the data source columns, you can click the Reset
   button.

To delete a mapping

1. Select the grid row that you want to delete.
2. Click Delete. This will cause the query to ignore that column in the source table and to not fill the dataset column with any data.

See Also

ADO.NET Overview

ADO.NET Component Designers

Handling Errors in Table Mappings

Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!