PrepAway - Latest Free Exam Questions & Answers

Which code segment should you use?

A Windows Forms application contains the following code segment.
Dim SQL As String = “SELECT OrderID, ProductID, UnitPrice, Quantity FROM [Order Details]” Dim da As New SqlDataAdapter(SQL, connStr)
Dim dt As New DataTable()
da.Fill(dt)

You need to add a new column to the data table named ItemSubtotal. The ItemSubtotal column must contain the value of the UnitPrice column multiplied by the value of the Quantity column. Which code segment should you use?

PrepAway - Latest Free Exam Questions & Answers

A.
Dim col As New DataColumn(“ItemSubtotal”)col.DataType = GetType(Decimal)col.Expression = “UnitPrice * Quantity”dt.Columns.Add(col)

B.
dt.Compute(“UnitPrice * Quantity”, “ItemSubtotal”)

C.
Dim col As New DataColumn(“ItemSubtotal”)col.DataType =
GetType(Decimal)dt.Columns.Add(col)dt.Compute(“UnitPrice * Quantity”, “ItemSubtotal”)

D.
Dim col As New DataColumn(“ItemSubtotal”)col.DataType = GetType(Decimal)col.DefaultValue = “UnitPrice * Quantity”dt.Columns.Add(col)


Leave a Reply