You create an application by using the Microsoft .NET Framework 3.5 and Microsoft ADO.NET. The application connects to a Microsoft SQL Server 2005 database.
You write the following code segment.
string sql = "Select InvoiceNo,OrderAmount from Orders";
SqlDataAdapter adp = new SqlDataAdapter(sql, con);
DataTable tblOrders = new DataTable();
adp.Fill(tblOrders);
If the value of the OrderAmount column is greater than 1000, then a discount of 5 percent is calculated.
You need to create a DataColumn object named Discount that contains the discount value for each row in the tblOrders DataTable.
Which code segment should you use?
A.
DataColumn col = new DataColumn("Discount");
col.Expression = "IIF(OrderAmount>1000,OrderAmount*5/100,0)";
tblOrders.Columns.Add(col);
B.
DataColumn col = new DataColumn("Discount");
col.DefaultValue = "IIF(OrderAmount>1000,OrderAmount*5/100,0)";
tblOrders.Columns.Add(col);
C.
DataColumn col = new DataColumn("Discount");
tblOrders.Columns.Add(col);
tblOrders.Compute("Discount=OrderAmount*5/100","OrderAmount>1000");
D.
DataColumn col = new DataColumn("Discount");
tblOrders.Columns.Add(col);
col.Expression= tblOrders.Compute("OrderAmount*5/100","OrderAmount>1000").ToString();