PrepAway - Latest Free Exam Questions & Answers

Which code segment should you insert at line 02?

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4.0 to create an application.
The application connects to a Microsoft SQL Server database.
The application uses a DataTable named OrderDetailTable that has the following columns:
* ID
* OrderID
* ProductID
* Quantity
* LineTotal

Some records contain a null value in the LineTotal field and 0 in the Quantity field.
You write the following code segment. (Line numbers are included for reference only.)

01 DataColumn column = new DataColumn(“UnitPrice”, typeof(double));
02 …
03 OrderDetailTable.Columns.Add(column);

You need to add a calculated DataColumn named UnitPrice to the OrderDetailTable object.
You also need to ensure that UnitPrice is set to 0 when it cannot be calculated.
Which code segment should you insert at line 02?

PrepAway - Latest Free Exam Questions & Answers

A.
column.Expression = “LineTotal/Quantity”;

B.
column.Expression = “LineTotal/ISNULL(Quantity, 1)”;

C.
column.Expression = “if(Quantity > 0, LineTotal/Quantity, 0)”;

D.
column.Expression = “iif(Quantity > 0, LineTotal/Quantity, 0)”;

Explanation:
IIF ( boolean_expression, true_value, false_value )


Leave a Reply