PrepAway - Latest Free Exam Questions & Answers

Which code segment should you use?

You use Microsoft .NET Framework 4.0 to develop an application that connects to a Microsoft SQL Server 2008 database.
You add the following stored procedure to the database.

CREATE PROCEDURE dbo.GetClassAndStudents
AS
BEGIN
SELECT * FROM dbo.Class
SELECT * FROM dbo.Student
END

You create a SqIConnection named conn that connects to the database.
You need to fill a DataSet from the result that is returned by the stored procedure.
The first result set must be added to a DataTable named Class, and the second result set must be added to a DataTable named Student.
Which code segment should you use?

PrepAway - Latest Free Exam Questions & Answers

A.
DataSet ds = new DataSet();
SqlDataAdapter ad = new SqlDataAdapter(�GetClassAndStudents�, conn);
ds.Tables.Add(�Class�);
ds.Tables.Add(�Student�);
ad.Fill(ds);

B.
DataSet ds = new DataSet();
SqlDataAdapter ad = new SqlDataAdapter(�GetClassAndStudents�, conn);
ad.TableMappings.Add(“Table�, �Class�);
ad.TableMappings.Add(�Table1�, �Student�) ;
ad.Fill(ds) ;

C.
DataSet ds = new DataSet();
SqlDataAdapter ad = new SqlDataAdapter(�GetClassAndStudents�, conn);
ad.MissingMappingAction = MissingMappingAction.Ignore;
ad.Fill(ds, �Class�);
ad.Fill(ds, �Student�);

D.
DataSet ds = new DataSet();
SqlDataAdapter ad = new SqlDataAdapter(�GetClassAndStudents�, conn);
ad.Fill(ds);

Explanation:
Table Mapping in ADO.NET
(http://msdn.microsoft.com/en-us/library/ms810286.aspx)


Leave a Reply