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 dbo.GetClossAndStudents
AS
BEGIN
SELECT * FROM ctoo.Class
SELECT * FROM dbo.Student
END
You create a SqlConnection 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?
A.
Dim ds As DataSet = New DataSet()
Dim ad As SqlDataAdapter = New SqlDataAdapter(
“GetClassAndStudents”, conn)
ad.Tab leMappings.Add(“Table”, “Class”)
ad.TableMappings.Add(“Tablel”, “Student”)
ad.Fill(ds)
B.
Dim ds As DataSet = New DataSet()
Dim ad As SqlDataAdapter = New SqlDataAdapter(
“GetClassAndStudents”, conn)
ad.MissingMappingAction = MissingMappingAction.Ignore ad.Fill(ds, “Class”) ad.Fill(ds, “Student”)
C.
Dim ds As DataSet = New DataSet()
Dim ad As SqlDataAdapter = New SqlDataAdapter(
“GetClassAndStudents”, conn)
ds. Tables . Add (“Class”)
ds.Tables.Add(“Student”) ad.Fill(ds)
D.
Dim ds As DataSet = New DataSet()
Dim ad As SqlDataAdapter = New SqlDataAdapter(
“GetClassAndStudents”, conn)
ad.Fill(ds)
Explanation:
Table Mapping in ADO.NET
(http://msdn.microsoft.com/en-us/library/ms810286.aspx)