Microsoft
70-516 · Question #209
70-516 Question #209: Real Exam Question with Answer & Explanation
Sign in or unlock 70-516 to reveal the answer and full explanation for question #209. The question stem and answer options stay visible for context.
Question
You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4.0 to create an application. You are creating the data layer of the application. You write the following code segment. (Line numbers are included for reference only.) 01 public static SqlDataReader GetDataReader(string sql) 02 { 03 SqlDataReader dr = null; 04 ... 05 return dr; 06 } You need to ensure that the following requirements are met: - The SqlDataReader returned by the GetDataReader method can be used to retreive rows from the database. - SQL connections opened within the GetDataReader method will close when the SqlDataReader is closed. Which code segment should you insert at the line 04?
Options
- Ausing(SqlConnection cnn = new SqlConnection(strCnn))
- BSqlConnection cnn = new SqlConnection(strCnn);
- CSqlConnection cnn = new SqlConnection(strCnn);
- DSqlConnection cnn = new SqlConnection(strCnn);
Unlock 70-516 to see the answer
You've previewed enough free 70-516 questions. Unlock 70-516 for full answers, explanations, the timed quiz mode, progress tracking, and the master PDF. Question stem and options stay visible so you can still see what's on the exam.