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
- Create an application.
- Add and configure database components.
- Set the table mappings in the TableMappings dialog.
Note: This procedure assumes you are using BDP.NET database components.
To create an application
- Choose FileNewWindows Forms Application for either Delphi for .NET or C#.
- Click the Data Explorer tab to display your data sources.
- Expand the list and locate a live data source.
- 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
- Select the BdpDataAdapter icon in the Component Tray.
- Click the Configure Data Adapter designer verb to open the Data Adapter Configuration dialog.
- Select the DataSet tab.
- Click the New DataSet radio button.
- Click OK. This creates a new dataset and displays an icon for it in the Component Tray.
To set table mappings
- Select the BdpDataAdapter icon in the Component Tray.
- Double-click the Collections field for the TableMappings property in the Object Inspector. This displays the TableMappings dialog.
- 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.
- 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.
- 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.
- 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.
- 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
- Select the grid row that you want to delete.
- 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.