Which code segment should you use?

You create an application by using the Microsoft .NET Framework 3.5 and Microsoft ADO.NET.

You write the following code segment.

DataTable tblInvDet = new DataTable("InvoiceDetail");
DataColumn colInvNo = tblInvDet.Columns.Add("InvNo", typeof(string));
DataColumn colItemNo = tblInvDet.Columns.Add("ItemNo", typeof(int));

You need to ensure that the corresponding values in the InvNo DataColumn and the ItemNo DataColumn form a unique pair.

Which code segment should you use?

You create an application by using the Microsoft .NET Framework 3.5 and Microsoft ADO.NET.

You write the following code segment.

DataTable tblInvDet = new DataTable("InvoiceDetail");
DataColumn colInvNo = tblInvDet.Columns.Add("InvNo", typeof(string));
DataColumn colItemNo = tblInvDet.Columns.Add("ItemNo", typeof(int));

You need to ensure that the corresponding values in the InvNo DataColumn and the ItemNo DataColumn form a unique pair.

Which code segment should you use?

A.
colInvNo.Unique = true;
colItemNo.Unique = true;

B.
UniqueConstraint con = new UniqueConstraint("UnqCol", new DataColumn[] { colInvNo, colItemNo }, false);
tblInvDet.Constraints.Add(con);

C.
UniqueConstraint con1 = new UniqueConstraint("UnqCol1", colInvNo, true);
UniqueConstraint con2 = new UniqueConstraint("UnqCol2", colItemNo, true);
tblInvDet.Constraints.Add(con1);
tblInvDet.Constraints.Add(con2);

D.
UniqueConstraint con1 = new UniqueConstraint("UnqCol1", colInvNo, false);
UniqueConstraint con2 = new UniqueConstraint("UnqCol2", colItemNo, false);
tblInvDet.Constraints.AddRange(new UniqueConstraint[] { con1,con2});



Leave a Reply 0

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