PrepAway - Latest Free Exam Questions & Answers

What are two possible code segments that you can use to achieve the goal?

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4.0 to create an application.
The application connects to a Microsoft SQL Server 2008 database. You add the following store 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 the goal?

PrepAway - Latest Free Exam Questions & Answers

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.


Leave a Reply