You create an application by using the Microsoft .NET Framework 3.5 and Microsoft
ADO.NET.The application contains a DataSet object named orderDS. The object contains a
table named Order as shown in the following exhibit.
The application uses a SqlDataAdapter object named daOrder to populate the Order table.
You write the following code segment. (Line numbers are included for reference only.)
01 private void FillOrderTable(int pageIndex) {
02 int pageSize = 5;
03
04 }
You need to fill the Order table with the next set of 5 records for each increase in the
pageIndex value.Which code segment should you insert at line 03?
A.
string sql = “SELECT SalesOrderID, CustomerID, OrderDate FROM
Sales.SalesOrderHeader”;
daOrder.SelectCommand.CommandText = sql;
daOrder.Fill(orderDS, pageIndex, pageSize, “Order”);
B.
int startRecord = (pageIndex – 1) * pageSize;
string sql = “SELECT SalesOrderID,
CustomerID, OrderDate FROM Sales.SalesOrderHeader”;
daOrder.SelectCommand.CommandText = sql;
daOrder.Fill(orderDS, startRecord, pageSize, “Order”);
C.
string sql = string.Format(“SELECT TOP {0} SalesOrderID, CustomerID, OrderDate
FROM Sales.SalesOrderHeader WHERE SalesOrderID > {1}”, pageSize, pageIndex);
daOrder.SelectCommand.CommandText = sql;
daOrder.Fill(orderDS, “Order”);
D.
int startRecord = (pageIndex – 1) * pageSize;
string sql = string.Format(“SELECT TOP {0} SalesOrderID, CustomerID, OrderDate
FROM Sales.SalesOrderHeader WHERE SalesOrderID > {1}”, pageSize, startRecord);
daOrder.SelectCommand.CommandText = sql;
daOrder.Fill(orderDS, “Order”);