The DataSet and Related Classes The following are the details for the DataSet and related items, such as DataRelation, DataTable, and so on. Constraint and ConstraintCollection This Constraint class represents a rule on a table that limits the data that can be modified. Table C.1 lists the properties of the Constraint class. Table C.1. Properties of the Constraint Class Property | Description | ConstraintName | The name of this constraint. | ExtendedProperties | Retrieves a collection of user-defined properties. | Table | Returns DataTable to which this constraint applies. | Table C.2 lists the property, methods, and event of the ConstraintCollection class. Table C.2. Property, Methods, and Event of the ConstraintCollection Class Property | Description | Item | Gets a constraint in the collection with either the name of the constraint or its index in the collection. | Method | Description | Add | Adds a constraint to the collection. This method is overloaded. See the .NET Framework SDK documentation for more information. | AddRange | Copies the elements from another ConstraintCollection object into the current one. | CanRemove | Indicates if a constraint specified by Constraint can be removed from the DataTable. | Clear | Clears the collection of all Constraint objects. | Contains | Indicates if the Constraint with the name name exists in the collection. | IndexOf | Retrieves the index of the specified constraint. This method is overloaded. See the .NET Framework SDK documentation for more information. | Remove | Removes the specified constraint from the collection. This method is overloaded. See the .NET Framework SDK documentation for more information. | RemoveAt | Removes the Constraint at the specified index. | Event | Description | CollectionChanged | Occurs when the collection is changed through additions or removals. Uses a CollectionChangeEventArgs object for the event parameter. This object contains the following properties: Action? Returns a value (Add, Remove, Refresh) indicating how the collection has changed. Element? Returns the instance of the collection that changed. | DataColumn and DataColumnCollection A DataColumn represents a column of information in a DataTable. Table C.3 lists the properties and method of the DataColumn class. Table C.3. Properties and Method of the DataColumn Class Property | Description | AllowDBNull | Indicates if null values are allowed in this column. | AutoIncrement | Indicates if the value of the column automatically increments with the addition of a new row. | AutoIncrementSeed | The starting value for AutoIncrement | AutoIncrementStep | The increment value used by AutoIncrement. | Caption | The caption for this column. | ColumnMapping | Returns a MappingType object indicating how the column is mapped when written as XML. | ColumnName | The name of the column. | DataType | The type of data stored in this column. | DefaultValue | The default value for this column when creating new rows. | Expression | A string expression used to filter rows, calculate the column's value, or create an aggregate column. | ExtendedProperties | Returns a PropertyCollection of custom user information. | MaxLength | The maximum length of a text column. | Namespace | The XML namespace containing the elements used in this column. | Ordinal | The position of this column in the DataColumnCollection. | Prefix | The prefix used for this column when represented as XML. | ReadOnly | Indicates if the column allows changes. | Table | Returns DataTable to which this column belongs. | Unique | Indicates if each value in the column must be unique. | Method | Description | ToString | Returns the Expression of this column, if one exists. | Table C.4 lists the property, methods, and event of the DataColumnCollection class. Table C.4. Property, Methods, and Event of the DataColumnCollection Class Property | Description | Item | Gets a DataColumn in the collection with either the name of the column or its index in the collection. | Method | Description | Add | Adds a column to the collection. This method is overloaded. See the .NET Framework SDK documentation for more information. | AddRange | Adds an array of DataColumn objects to the collection. | CanRemove | Indicates if a column specified by Column can be removed from the collection. | Clear | Clears the collection of all DataColumn objects. | Contains | Indicates if the DataColumn with the name name exists in the collection. | IndexOf | Retrieves the index of the specified column. This method is overloaded. See the .NET Framework SDK documentation for more information. | Remove | Removes the specified column from the collection. This method is overloaded. See the .NET Framework SDK documentation for more information. | RemoveAt | Removes the DataColumn at the specified index. | Event | Description | CollectionChanged | Occurs when the collection is changed through additions or removals. Uses a CollectionChangeEventArgs object for the event parameter. This object contains the following properties: Action? Returns a value (Add, Remove, Refresh) indicating how the collection has changed. Element? Returns the instance of the collection that changed. | DataRelation and DataRelationCollection A DataRelation class represents the relationship between multiple tables in the DataSet. Table C.5 lists the properties of the DataRelation class. Table C.5. Properties of the DataRelation Class Property | Description | ChildColumns | Returns an array of DataColumn objects that represent the child columns of this relation. | ChildKeyConstraint | A ForeignKeyConstraint object for this relation. | ChildTable | Returns a DataTable representing the child table of this relation. | DataSet | Returns the DataSet to which this relation belongs to. | ExtendedProperties | Returns a PropertyCollection of custom user information. | Nested | Indicates if relations are nested. | ParentColumns | An array of DataColumn objects that represent the parent columns of this relation. | ParentKeyConstraint | A UniqueConstraint object for this relation. | ParentTable | Returns the DataTable representing the parent table of this relation. | RelationName | The name of this relation. | Table C.6 lists the property, methods, and event of the DataRelationCollection class. Table C.6. Property, Methods, and Event of the DataRelationCollection Class Property | Description | Item | Gets a DataRelation in the collection with either the name of the relation or its index in the collection. | Method | Description | Add | Adds a relation to the collection. This method is overloaded. See the .NET Framework SDK Documentation for more information. | AddRange | Adds an array of DataRelation objects to the collection. | CanRemove | Verifies whether the specified DataRelation can be removed from the collection. | Clear | Clears the collection of all DataRelationobjects. | Contains | Indicates if the DataRelation with the name name exists in the collection. | IndexOf | Returns the index of the specified DataRelation. | Remove | Removes the specified relation from the collection. This method is overloaded. See the .NET Framework SDK Documentation for more information. | RemoveAt | Removes the DataRelation at the specified index. | CollectionChanged | Occurs when the collection is changed through additions or removals. Uses a CollectionChangeEventArgs object for the event parameter. This object contains the following properties: Action? Returns a value (Add, Remove, Refresh) indicating how the collection has changed. Element? Returns the instance of the collection that changed. | DataRow and DataRowCollection A DataRow represents a row of information in a DataTable, that is, an individual record of data. Table C.7 lists the properties and methods of the DataRow class. Table C.7. Properties and Methods of the DataRow Class Property | Description | HasErrors | Indicates if the data in the row contains any errors. | Item | Specifies the data contained in the specified column. The method is overloaded. See the .NET Framework SDK documentation for more details. | ItemArray | Specifies the data contained in the entire row, through an array. | RowError | The custom error description for the row. | RowState | The state of the row. Can be Detached, Unchanged, New, Deleted, or Modified. | Table | Returns DataTable to which this row belongs. | Method | Description | AcceptChanges | Commits all changes made to the row. | BeginEdit | Begins an edit operation on the row. | CancelEdit | Cancels an edit operation, repealing edits. | ClearErrors | Clears all errors for the row. | Delete | Deletes the row. | EndEdit | Ends the edit operation on the row. | GetChildRows | Returns an array of DataRow objects representing the child rows of this row, when using the specified DataRelation. | GetColumnError | Gets the error for a specified column in the row. This method is overloaded. See the .NET Framework SDK documentation for more information. | GetColumnsInError | Gets an array of DataColumn objects that have errors. | GetParentRow | Returns a DataRow representing the parent of this row. This method is overloaded. See the .NET Framework SDK documentation for more details. | GetParentRows | Returns an array of DataRow objects representing the parent of this row using the specified DataRelation. This method is overloaded. See the .NET Framework SDK documentation for more details. | HasVersion | Indicates if a specified version of the row exists. | IsNull | Indicates if the specified column in the row contains a null value. This method is overloaded. See the .NET Framework SDK documentation for more details. | RejectChanges | Rolls back all changes made to the row. | SetColumnError | Sets the error description for the column. This method is overloaded. | SetParentRow | Sets the parent row of a given child row. This method is overloaded. | Table C.8 lists the property and methods of the DataRowCollection class. Table C.8. Property and Methods of the DataRowCollection Class Property | Description | Item | Gets a DataRow in the collection with either the name of the row or its index in the collection. | Method | Description | Add | Adds a row to the collection. This method is overloaded. | Clear | Clears the collection of all DataRow objects. | Contains | Indicates if the DataRow with the name name exists in the collection. | Find | Gets a specified DataRow. This method is overloaded. | InsertAt | Inserts a new DataRow at the specified location. | Remove | Removes the specified row from the collection. This method is overloaded. | RemoveAt | Removes the DataRow at the specified index. | DataSet Table C.9 lists the properties, methods, and event of the DataSet class, which represents a disconnected data source. Table C.9. Properties, Methods, and Event of the DataSet Class Property | Description | CaseSensitive | Indicates if string comparisons in a DataTable are case-sensitive. | DataSetName | The name of this DataSet. | DefaultViewManager | Returns a DataViewManager that contains a customized view of the data in the DataSet. | EnforceConstraints | Indicates if constraint rules are followed when updating the data. | ExtendedProperties | A PropertyCollection object containing custom user information. | HasErrors | Indicates if the data in any of the rows of this DataSet contain errors. | Locale | The locale information used to compare strings. Returns a CultureInfo object. | Namespace | Indicates the namespace of the DataSet. | Prefix | An XML alias for the namespace of the DataSet. | Relations | A DataRelationCollection object that represents all relations between tables in the DataSet. | Site | Returns an ISite interface for the DataSet (used to bind components to containers). | Tables | A DataTableCollection object representing all tables in the DataSet. | Method | Description | AcceptChanges | Commits all changes made to the DataSet. | Clear | Removes all rows in all tables in the DataSet. | Clone | Produces a DataSet identical to the current DataSet, without data. | Copy | Produces a DataSet identical to the current DataSet, with data. | GetChanges | Produces a DataSet that contains only the data that has changed. | GetXml | Returns the data in the DataSet in XML format. | GetXmlSchema | Returns the XML schema for the data in the DataSet. | HasChanges | Indicates if the data in the DataSet has changed at all. | InferXmlSchema | Builds the data structure from an XML data source. This function is overloaded; see the .NET SDK documentation for more details. | Merge | Merges the specified DataSet with the one specified. | ReadXml | Inserts data and schema information from an XML file in a DataSet. | ReadXmlSchema | Builds the data structure from an XML schema. This function is overloaded; see the .NET SDK documentation for more details. | RejectChanges | Undoes all changes that have been made to this DataSet. | Reset | Resets the DataSet to its default properties. | WriteXml | Writes the content of the DataSet in XML format. This function is overloaded; see the .NET SDK documentation for more details. | WriteXmlSchema | Writes the structure of the DataSet in XML format. This function is overloaded; see the .NET SDK Documentation for more details. | Event | Description | MergeFailed | Occurs when a target and source DataRow have the same primary key value, and EnforceConstraints is true. | DataTable and DataTableCollection A DataTable represents a table of information in a DataSet. Table C.10 lists the properties, methods, and events of the DataTable class. Table C.10. Properties, Methods, and Events of the DataTable Class Property | Description | CaseSensitive | Indicates if string comparisons in the table are case-sensitive. | ChildRelations | Returns a DataRelationCollection of the child relations of this table. | Columns | Returns a DataColumnCollection object representing the column in this table. | Constraints | Returns a DataRelationCollection object representing the data relations in this table. | DataSet | Returns the DataSet this table belongs to. | DefaultView | Returns a DataView representing a customized view of the data in this table. | DisplayExpression | A string expression that returns a value indicating how to display this table in the UI. | ExtendedProperties | Returns a PropertyCollection of custom user information. | HasErrors | Indicates if there are any errors in any of the rows of this table. | Locale | A CultureInfo object used to determine how strings are compared. | MinimumCapacity | The initial starting size for this table. | Namespace | The XML namespace containing the elements used in this table. | ParentRelations | A DataRelationCollection of the parent relations of this table. | Prefix | The prefix used for this table when represented as XML. | PrimaryKey | An array of DataColumn objects that serve as the primary keys of the table. | Rows | A DataRowCollection object representing the rows belonging to this table. | Site | Returns an ISite interface for the DataTable (used to bind components to containers). | TableName | The name of the table. | Method | Description | AcceptChanges | Commits all changes made to this table. | BeginInit | Begins the initialization of this table. | BeginLoadData | Begins the data loading process. | Clear | Clears the table of all data. | Clone | Makes a copy of the DataTable's structure, including all its relations. | Compute | Computes the expression specified in the first parameter on the rows that pass the specified filter. | Copy | Copies both the structure and data contained in the DataTable. | EndInit | Ends the initialization process. | EndLoadData | Ends the data loading process. | GetChanges | Gets a copy of the DataTable that contains only the changes made to it since it was first created, or since AcceptChanges was called. | GetErrors | An array of DataRow objects that contain errors. | ImportRow | Copies a DataRow object into the DataTable. | LoadDataRow | Finds and updates a DataRow with the specified values. If a row is not found, a new one is created. | NewRow | Returns a blank DataRow with the same schema as the table. | RejectChanges | Rolls back all changes made to the table since it was first loaded or since AcceptChanges was last called. | Reset | Resets the DataTable to its default properties. | Select | Returns an array of DataRow objects. This method is overloaded. | ToString | Returns the TableName and DisplayExpression of this table. | Event | Description | ColumnChanged | Occurs when a column has changed. Uses a DataColumnChangedEventArgs object for the event parameter. This object contains the following properties: Column? The column that changed. ProposedValue The value to change to column to. Row? The DataRow to change. | ColumnChanging | Occurs when changes have been submitted for this column. Uses a DataColumnChangedEventArgs object. | RowChanged | Occurs when a row has changed. Uses a DataRowChangedEventArgs object for the event parameter. This object contains the following properties: Action? The action that occurred on the DataRow. Row? Thse DataRow to change. | RowChanging | Occurs when changes have been submitted for this column. Uses a DataRowChangedEventArgs object. | RowDeleted | Occurs after a row is deleted. Uses a DataRowChangedEventArgs object. | RowDeleting | Occurs before a row is deleted. Uses a DataRowChangedEventArgs object. | Table C.11 lists the property, methods, and events of the DataTableCollection class. Table C.11. Property, Methods, and Events of the DataTableCollection Class Property | Description | Item | Gets a DataTable in the collection with either the name of the table or its index in the collection. | Methods | Description | Add | Adds a table to the collection. This method is overloaded. | AddRange | Adds an array of DataTable objects to the collection. | CanRemove | Indicates if the table specified can be removed from the collection. | Clear | Clears the collection of all DataTable objects. | Contains | Indicates if the DataTable with the specified name exists in the collection. | IndexOf | Retrieves the index of the specified table. This method is overloaded. | Remove | Removes the specified table from the collection. This method is overloaded. | RemoveAt | Removes the DataTable at the specified index. | Event | Description | CollectionChanged | Occurs when the collection is changed through additions or removals. Uses a CollectionChangeEventArgs object for the event parameter. This object contains the following properties: Action? Returns a value (Add, Remove, Refresh) indicating how the collection has changed. Element? Returns the instance of the collection that changed. | CollectionChanging | Occurs before the collection is changed. Uses a CollectionChangeEventArgs object. | DataView A DataView class represents a customized view of the data in a DataSet. Table C.12 lists the properties, methods, and event of the DataView class. Table C.12. Properties, Methods, and Event of the DataView Class Property | Description | AllowDelete | Indicates if deletes are allowed in this view. | AllowEdit | Indicates if edit are allowed in this view. | AllowNew | Indicates if new rows can be added in this view. | ApplyDefaultSort | Indicates if the default sort should be used. | Count | Returns the number of records in the DataView. | DataViewManager | The DataView that created this view (a pointer to the DataSetView that owns the corresponding DataSet). | Item | Gets a specified row of data from a table. | RowFilter | An expression used to filter which rows are added to the DataView. | RowStateFilter | Specifies which version of rows is added to the DataView. Can be None, Unchanged, New, Deleted, ModifiedCurrent, ModifiedOriginal, OriginalRows, and CurrentRows (default). | Sort | The columns to sort by. | Table | The source DataTable from which to pull data. | Methods | Description | AddNew | Adds a new row to the DataView. | BeginInit | Begins the initialization of this DataView. | CopyTo | Copies items into an array. | Delete | Deletes a row at the specified index. | EndInit | Ends the initialization process. | Find | Finds a specified row in the DataView. This method is overloaded. | FindRows | Returns an array of DataRowView objects that match the specified criteria. | GetEnumerator | Returns an IEnumerator that can be used to iterate through this DataView. | Event | Description | ListChanged | Occurs when the list managed by the DataView changes. Uses a ListChangedEventArgs object for the event parameter. This object contains the following properties: ListChangedType? The way the list changed. NewIndex The new index of the item that changed. OldIndex? The old index of the item that changed. | |