Which code segment should you add?

You create an application by using the Microsoft .NET Framework 3.5 and Microsoft
ADO.NET.The application uses a Microsoft SQL Server 2005 database that contains a
Products table and an Inventory table.The application coordinates updates between the
records in the Products table and Inventory table by loading a DataSet class named DataSet1.
You write the following code segment.
DataColumn parentColumn = DataSet1.Tables[“Products”].Columns[“ProductID”];
DataColumn childColumn = DataSet1.Tables[“Inventory”].Columns[“ProductID”];
You need to ensure that the following requirements are met when the ProductID value is
modified in the Products table:
The ProductID value is unique.
The records in the Inventory table are updated with the new ProductID value.
Which code segment should you add?

You create an application by using the Microsoft .NET Framework 3.5 and Microsoft
ADO.NET.The application uses a Microsoft SQL Server 2005 database that contains a
Products table and an Inventory table.The application coordinates updates between the
records in the Products table and Inventory table by loading a DataSet class named DataSet1.
You write the following code segment.
DataColumn parentColumn = DataSet1.Tables[“Products”].Columns[“ProductID”];
DataColumn childColumn = DataSet1.Tables[“Inventory”].Columns[“ProductID”];
You need to ensure that the following requirements are met when the ProductID value is
modified in the Products table:
The ProductID value is unique.
The records in the Inventory table are updated with the new ProductID value.
Which code segment should you add?

A.
DataRelation relCustOrder = new DataRelation(“ProductsInventory”, parentColumn,
childColumn);
DataSet1.Relations.Add(relCustOrder);

B.
ForeignKeyConstraint productOrderFK = new ForeignKeyConstraint(parentColumn,
childColumn);
productOrderFK.UpdateRule = Rule.SetDefault;
DataSet1.Tables[“Inventory”].Constraints.Add(productOrderFK);

C.
DataRelation relProdInvent = new DataRelation(“ProductsInventory”, parentColumn,
childColumn);
DataSet1.Relations.Add(relProdInvent);
DataSet1.Relations[“ProductsInventory”].ChildKeyConstraint.UpdateRule = Rule.SetNull;

D.
DataRelation relProdInvent = new DataRelation(“ProductsInventory”, childColumn,
parentColumn); DataSet1.Relations.Add(relProdInvent);
ForeignKeyConstraint productInvFK =
DataSet1.Relations[“ProductsInventory”].ChildKeyConstraint;
productInvFK.UpdateRule = Rule.SetDefault;

Explanation:
DataRelation-represents a parent/child relationship between two System.Data.DataTable objects.



Leave a Reply 0

Your email address will not be published. Required fields are marked *