nerdexam
Microsoft

70-516 · Question #58

70-516 Question #58: Real Exam Question with Answer & Explanation

Sign in or unlock 70-516 to reveal the answer and full explanation for question #58. 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 create a stored procedure to insert a new record in the Categories table according to following code segment. CREATE PROCEDURE dbo.InsertCategory @CategoryName navrchar(15), @Identity int OUT AS INSERT INTO Categories(CategoryName) VALUES (@CategoryName) SET @Identity = SCOPE_IDENTITY() RETURN @@ROWCOUNT You add the following code fragment. (Line numbers are included for reference only.) 01 private static void ReturnIdentity(string connectionString) 02 { 03 using(SqlConnection connection = new SqlConnection(connectionString)) 04 { 05 SqlDataAdpater adapter = new SqlDataAdapter("SELECT CategoryID, CategoryName FROM dbo.Categories", connection); 06 adapter.InsertCommand = new SqlCommand("InsertCategory", connection); 07 adapter.InsertCommand.CommandType = CommandType.StoredProcedure; 08 SqlParameter rowcountParameter = adapter.InsertCommand.Parameters.Add("@RowCount", SqlDbType.Int); 09 ... 10 adapter.InsertCommand.Parameters.Add("@CategoryName", SqlDbType.NChar, 15, "CategoryName"); 11 SqlParameter identityParameter = adapter.InsertCommand.Parameters.Add("@Identity", SqlDbType.Int, 0, "CategoryID"); 12 ... 13 DataTable categories = new DataTable(); 14 adapter.Fill(categories); 15 DataRow ctegoryRow = categories.NewRow(); 16 categoryRow["CategoryName"] = "New beverages"; 17 categories.Rows.Add(categoryRow); 18 adapter.Update(categories); 19 Int32 rowCount = (Int32)adapter.InsertCommand.Parameters["@RowCount"].Value; 20 } 21 } Which code elements needs to be added in the empty lines?

Options

  • AInsert the following code segment at line 09:
  • BInsert the following code segment at line 09:
  • CInsert the following code segment at line 09:
  • DInsert the following code segment at line 09:

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.

Full 70-516 Practice