nerdexam
Microsoft

70-516 · Question #203

70-516 Question #203: Real Exam Question with Answer & Explanation

The correct answer is D. column.Expression = "iif(Quantity > 0, LineTotal/Quantity, 0)";. IIF ( boolean_expression, true_value, false_value )

Question

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?

Options

  • Acolumn.Expression = "LineTotal/Quantity";
  • Bcolumn.Expression = "LineTotal/ISNULL(Quantity, 1)";
  • Ccolumn.Expression = "if(Quantity > 0, LineTotal/Quantity, 0)";
  • Dcolumn.Expression = "iif(Quantity > 0, LineTotal/Quantity, 0)";

Explanation

IIF ( boolean_expression, true_value, false_value )

Community Discussion

No community discussion yet for this question.

Full 70-516 Practice