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.)
A.
Insert the following code at line 09.
parNum.Direction = ParameterDirection.Input;
B.
Insert the following code at line 09.
parNum.Direction = ParameterDirection.Output;
C.
Insert the following code at line 11.
int numEnrolled = 0;
SqlDataReader reader = cmd.ExecuteReader();
while(reader.Read())
{
numEnrolled = numEnrolled + (int)cmd.Parameters[“@NumEnrolled”].Value;
}
return numEnrolled;
D.
Insert the following code at line 11.
cmd.ExecuteNonQuery();
return (int)parNum.Value;
I attended to a 70-516 exam, and passed it with 884 score, so I decided to write my excperience here, maybe someone will read it here at the first question while studying for that.
This set of questions are valid and a lot of (~80%) them came up on the actual exam. But please note that some questions are slighty modified to these ones, but the answers are the same. I recommend to look at the other answers at each question, and think about that ‘What would be the perfect question for this answer?’.
The other set of questions here (v1) are made by some third party exam school, and are not original MS exam questions, but good for practice.
*About the exam: It was 120 mins long and there were 10+55 questions. The first 10 question in connection with a case study, that is not detailed on this site, but the question for that are between Q#48-Q#64. All questions that are about Parts, Products and Components (and Colors).
The other 55 question are mostly from this set, there were some new ones, and some drag and drop that is not detailed in here. The questions Q#11 and Q#19 were on the exam a bit modified, I wrote a comment about for those.
I hope my short summary can help you to pass the exam. I you have any questions feel free to drop me an email, or write a comment about it, I will check back some times.