RAD Studio for Microsoft .NET
ContentsIndex
PreviousUpNext
Handling Errors in Table Mapping

Whenever you perform any type of comparison function between a data source and an in-memory data representation, there is potential for error. Errors can occur when a data source and its corresponding dataset do not share uniform numbers of columns, or when column types in a data source do not correspond to the column types in the dataset. In addition, other, internal errors can occur for which there is no designtime workaround. You can use both the MissingMappingAction property and the MissingSchemaAction property to respond to errors in your table mapping operations. Use the MissingMappingAction when you want to specify how the adapter should respond when the mapping is missing. Use the MissingSchemaAction when you want to specify how the adapter should respond when it tries to write data to a column that isn't defined in the dataset.

To set the MissingMappingAction property

  1. Once you have created an AdoDbxDataAdapter and have set up your table mappings, click the drop down list next to the MissingMappingAction property in the Object Inspector.
  2. Select Passthrough if you want the adapter to load the data source column data into a dataset column of the same name, or, if there is no corresponding dataset column, if you want the adapter to perform the action specified in the MissingSchemaAction property.
  3. Select Ignore if you want to keep data from being loaded when data source columns are not properly mapped to dataset columns. This could occur if mapped columns are of incompatible data types, lengths, or have other errors.
  4. Select Error if you want the adapter to raise an error that you can trap.

To set the MissingSchemaAction property

  1. Select Add if you want the data source table or column added to the dataset and its schema. Setting the MissingMappingAction property to Passthrough and the MissingSchemaAction to Add results in a duplication of data source table and column names in the dataset.
  2. Select AddWithKey if you want the data source table or column added to the dataset and its schema along with the table's or column's primary key information.
  3. Select Ignore if you don't want a table or column added to the dataset, when that table or column aren't already represented in the dataset schema. Specify Ignore when you want the dataset loaded only with data explicitly specified in the table mappings. This may be necessary if your adapter calls a stored procedure or a user-defined SQL statement that returns more columns than are defined in the dataset.
  4. Select Error if you want the adapter to raise an error that you can trap.

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