You use Microsoft .NET Framework 4 to develop an application that connects to a Microsoft SQL
Server 2008 database. You add the following stored procedure to the database.
CREATE PROCEDURE GetProducts
AS
BEGIN
SELECT ProductID, Name, Price, Cost
FROM Product
END
You create a SqlDataAdapter named adapter to execute the stored procedure. You need to fill a
DataTable instance with the first 10 rows of the result set. What are two possible code segments
that you can use to achieve this goal? (Each correct answer presents a complete solution. Choose
two.)
A.
DataSet ds = new DataSet();
adapter.Fill(ds, 0, 10, “Product”)
B.
DataSet ds = new DataSet();
DataTable dt = ds.Tables.Add(“Product”);
adapter.Fill(0, 10, dt);
C.
DataSet ds = new DataSet();
DataTable dt = ds.Tables.Add(“Product”);
dt.ExtendedProperties[“RowCount”] = 10;
dt.ExtendedProperties[“RowIndex”] = 0;
adapter.Fill(dt);
D.
DataSet ds = new DataSet();
ds.ExtendedProperties[“RowCount”] = 10;
ds.ExtendedProperties[“RowIndex”] = 0;
adapter.Fill(ds);
Explanation:
Fill(Int32, Int32, DataTable()) Adds or refreshes rows in a DataTable to match those in the data
source starting at the specified record and retrieving up to the specified maximum number of
records. (Inherited from DbDataAdapter.)
Fill(DataSet, Int32, Int32, String) Adds or refreshes rows in a specified range in the DataSet to match
those in the data source using the DataSet and DataTable names. (Inherited from DbDataAdapter.)
SqlDataAdapter Class
(http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqldataadapter.aspx)
DataTable.ExtendedProperties Gets the collection of customized user information.