nerdexam
Microsoft

70-516 · Question #110

You use Microsoft .NET Framework 4 to develop an application that connects to a Microsoft SQL Server 2008 database. The database contains a ClassStudent table that contains the StudentID for…

The correct answer is B. Insert the following code at line 09. D. Insert the following code at line 11. See the full explanation below for the reasoning.

Question

You use Microsoft .NET Framework 4 to develop an application that connects to a Microsoft SQL Server 2008 database. The database contains a ClassStudent table that contains the StudentID for students who are enrolled in the classes. You add the following stored procedure to the database. CREATE PROCEDURE [dbo].[GetNumEnrolled] @ClassID INT, @NumEnrolled INT OUTPUT AS BEGIN SET NOCOUNT ON SELECT @NumEnrolled = COUNT(StudentID) FROM ClassStudent WHERE (ClassID = @ClassID) END You write the following code. (Line numbers are included for reference only.) 01 private int GetNumberEnrolled(string classID) 02 { 03 using (SqlConnection conn = new SqlConnection(GetConnectionString()) 04 { 05 SqlCommand cmd = new SqlCommand("GetNumEnrolled", conn); 06 cmd.CommandType = CommandType.StoredProcedure; 07 SqlParameter parClass = cmd.Parameters.Add("@ClassID", SqlDbType.Int, 4, "classID"); 08 SqlParameter parNum = cmd.Parameters.Add("@NumEnrolled", SqlDbType.Int); 09 ... 10 conn.Open() 11 ... 12 } 13 } You need to ensure that the GetNumberEnrolled method returns the number of students who are enrolled for a specific class. Which two actions should you perform? (Each correct answer presents part of the solution. Choose two.)

Options

  • AInsert the following code at line 09.
  • BInsert the following code at line 09.
  • CInsert the following code at line 11.
  • DInsert the following code at line 11.

How the community answered

(19 responses)
  • A
    5% (1)
  • B
    74% (14)
  • C
    21% (4)

Community Discussion

No community discussion yet for this question.

Full 70-516 Practice