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. (Line numbers are included for reference only.)
01 SqlConnection sqlconn
02 …
03 SqlDataAdapter ordAdapter =
04 new SqlDataAdapter(
05 SELECT OrderID, CustomerID, OrderDate, Qty, UnitPrice,"+
06 "UnitMargin FROM Sales.SalesOrderDetail", sqlconn);
07 DataSet ord_ds = new DataSet();
08 DataTable ord_dt = ord_ds.Tables.Add("Orders");
09 ordAdapter.Fill(ord_dt);
10 ord_dt.Rows[0].BeginEdit();
11 // The code here will insert, update and delete rows to the ord_dt DataTable.
12 ord_dt.Rows[0].EndEdit();
13
14 ord_dt.AcceptChanges();
You need to validate that every row that has the Qty column value is set to zero before you commit any changes.
Which code segment should you insert at line 13?
A.
DataRow[] newRows = ord_dt.Select(null, null, DataViewRowState.CurrentRows);
foreach (DataRow newrow in newRows)
{
if(newrow.Field<int>("Qty",DataRowVersion.Current) == 0)
…
}
B.
DataRow[] newRows = ord_dt.Select(null, null, DataViewRowState.CurrentRows);
foreach (DataRow newrow in newRows)
{
if(newrow.Field<int>("Qty",DataRowVersion.Original) == 0)
…
}
C.
DataRow[] newRows = ord_dt.Select(null, null, DataViewRowState.ModifiedCurrent);
foreach (DataRow newrow in newRows)
{
if(newrow.Field<int>("Qty",DataRowVersion.Current) == 0)
…
}
D.
DataRow[] newRows = ord_dt.Select(null, null, DataViewRowState. ModifiedCurrent);
foreach (DataRow newrow in newRows)
{
if(newrow.Field<int>("Qty",DataRowVersion.Original) == 0)
…
}