Name

MissingSchemaAction

Synopsis

This enumeration specifies what happens when adding information to a DataSet and the schema information can’t be found. This enumeration is used when merging two DataSet objects (with the DataSet.Merge( ) method) and when filling a DataSet from a data source using the IDataAdapter.Fill( ) method. In the first case, a MissingSchemaAction value is specified as a parameter. In the second case, a MissingSchemaAction value is set using the IDataAdapter.MissingSchemaAction property.

If set to Add, the new missing DataColumn objects are added to the DataSet. If set to AddWithKey (the default when filling a DataSet), the required DataColumn objects are added, and ADO.NET tries to determine the primary key. In the case of the SQL Server provider, this involves appending the FOR BROWSE clause on the SQL statement and parsing out the additional information. In the case of an OLE DB provider, this involves setting the DBPROP_UNIQUEROWS property, and then determining which columns are primary key columns by examining DBCOLUMN_KEYCOLUMN in the IColumnsRowset. (Not all OLE DB providers support this technique. If you experience problems, use Add instead of AddWithKey and set the primary key manually.) Finally, you can specify Ignore, in which case data in a missing column will not be added, or Error, in which case a System.SystemException is thrown if data is encountered for a column that doesn’t exist.

public enum MissingSchemaAction {

   Add = 1,

   Ignore = 2,

   Error = ...

Get ADO.NET in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.