Answer 1
Analysis. Answer option D is correct.
Since Peter wants the application to display data from both DataTable1 and DataTable2, he must relate the two objects to each other. The DataRelation class is used to relate two DataTable objects to each other through DataColumn objects. DataRelation objects are contained in DataRelationCollection, and can be accessed through the Relations property of the DataSet object.
== What is DataRelation==
DataRelation is a class representing a parent/child relationship between two DataTable objects. Before creating a relationship, DataRelation verifies whether or not a relationship can be established. It creates a relationship between the matching columns in the parent and child tables.
Answer option A is incorrect. The Merge method of the DataSet class is used to incorporate the latest changes from a data source into an existing DataSet object. Following are the signatures of the Merge method:
Signature Description
Overloads Public Sub Merge(DataRow()) It is used to merge a DataSet object with an array of DataRow objects.
Overloads Public Sub Merge(DataSet) It is used to merge a DataSet object with a specified DataSet object.
Overloads Public Sub Merge(DataTable) It is used to merge a DataSet object with a specified DataTable object.
Overloads Public Sub Merge(DataSet, Boolean) It is used to merge a DataSet object with a specified DataSet object. It preserves changes according to the specified argument.
Overloads Public Sub Merge(DataRow(),
Boolean, MissingSchemaAction) It is used to merge a DataSet object with an array of DataRow objects. It preserves changes according to the specified argument and handles an incompatible schema according to the specified MissingSchemaAction.
Overloads Public Sub Merge(DataSet,
Boolean, MissingSchemaAction) It is used to merge a DataSet object with a specified DataSet object. It preserves changes according to the specified argument and handles an incompatible schema according to the specified MissingSchemaAction.
Overloads Public Sub Merge(DataTable,
Boolean, MissingSchemaAction) It is used to merge a DataSet object with a specified DataTable object. It preserves changes according to the specified argument and handles an incompatible schema according to the specified MissingSchemaAction.
Answer options B and C are incorrect. The PrimaryKey property of the DataTable class specifies an array of columns that are used to make up the primary key for a DataTable object. DataTable objects cannot be related to each other by creating primary keys.
== What is DataSet==
DataSet is a memory-resident representation of data. It represents related tables, constraints, and relationships among the tables. DataSet reads and writes data and schema as XML documents.
