You create an application by using the Microsoft .NET Framework version 3.5. You use Microsoft ADO.NET to access data for the application.
The application connects to a Microsoft SQL Server 2005 database. The database contains invoice records of customers in the Customer and Invoice tables.
You write the following code segment.
DataSet ds = new DataSet();
DataTable tblCust = ds.Tables.Add("Customer");
DataTable tblInv = ds.Tables.Add("Invoice");
DataColumn colPar = tblCust.Columns.Add("ID", typeof(int));
tblCust.Constraints.Add("PKey", colPar, true);
tblInv.Columns.Add("InvNo", typeof(string));
DataColumn colChild = tblInv.Columns.Add("CustomerID", typeof(int));
DataRow[] relatedRows;
//Retrieve data for Customer and Invoice
You need to retrieve the invoice details from the tblInv DataTable for customer records that have a value 1 in the ID column of the tblCust DataTable.
Which code segment should you use?
A.
DataRelation rel = new DataRelation("RelCust", colPar, colChild);
ds.Relations.Add(rel);
relatedRows = tblCust.Rows.Find(1).GetChildRows("RelCust");
B.
DataRelation rel = new DataRelation("RelCust", colPar, colChild);
ds.Relations.Add(rel);
relatedRows = tblCust.Rows.Find(1).GetParentRows("RelCust");
C.
ForeignKeyConstraint con = new ForeignKeyConstraint("RelCust", colPar, colChild);
tblInv.Constraints.Add(con);
relatedRows = tblCust.Rows.Find(1).GetChildRows("RelCust");
D.
ForeignKeyConstraint con = new ForeignKeyConstraint("RelCust", colPar, colChild);
tblInv.Constraints.Add(con);
relatedRows = con.RelatedTable.Rows.Find(1).GetChildRows("RelCust");