nerdexam
Microsoft

70-516 · Question #203

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…

Sign in or unlock 70-516 to reveal the answer and full explanation for question #203. The question stem and answer options stay visible for context.

Manipulating and Validating Data

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)";

Unlock 70-516 to see the answer

You've previewed enough free 70-516 questions. Unlock 70-516 for full answers, explanations, the timed quiz mode, progress tracking, and the master PDF. Question stem and options stay visible so you can still see what's on the exam.

Topics

#DataColumn expression#iif function#computed columns#null handling
Full 70-516 Practice