O'Reilly logo

Microsoft® Visual Basic® .NET Programmer's Cookbook by Matthew MacDonald

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Use Column and Table Mappings

Problem

You want to map database column and table names to the names expected by your code for the DataSet.

Solution

Create ColumnMapping objects for each column and DataTableMapping objects for each table, and assign them to the DataAdapter.TableMappings collection.

Discussion

The DataAdapter provides a layer of indirection between the data source and the DataSet. Using the DataAdapter, you can configure table and column mappings so that code remains unchanged when the data source changes (or vice versa).

Column mappings link a field in the data source with a differently named field in the DataSet. The following example shows how you might modify names in the Categories table when filling a DataSet: Source fields like ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required