PrepAway - Latest Free Exam Questions & Answers

Which code segment should you use?

A Windows Forms application contains the following code segment.
string SQL =
@"SELECT OrderID, ProductID, UnitPrice, Quantity FROM [Order Details]";
SqlDataAdapter da = new SqlDataAdapter(SQL, connStr); Data Table dt = new Data Table();
da.Fill(dt);

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

PrepAway - Latest Free Exam Questions & Answers

A.
DataColumn col = new DataColumn("ItemSubTotal");
col.DataType – typeof(decimal);
col.Expression = "UnitPrice * Quantity";
Dt.Column.Add(col);

B.
dt.Compute("UnitPrice * Quantity", ""ItemSubtotal");

C.
DataColumn col = DataColumn("ItemSubtotal");
col.DataType – typeof(decimal);
dt.Column.Add(col);
dt.Compute("UnitPrice * Quantity", ""ItemSubtotal");

D.
DataColumn col = new DataColumn("ItemSubtotal");
col.DataType – typeof(decimal);
col.DefaultValue = "UnitPrice * Quantity";
dt.Colums.Add(col);


Leave a Reply