nerdexam
Microsoft

70-516 · Question #43

The database contains a table named Categories. The Categories table has a primary key identity column named CategoryID. The application inserts new records by using the following stored procedure…

The correct answer is C. SqlParameter parameter =. See the full explanation below for the reasoning.

Question

The database contains a table named Categories. The Categories table has a primary key identity column named CategoryID. The application inserts new records by using the following stored procedure. CREATE PROCEDURE dbo.InsertCategory @CategoryName nvarchar(15), @Identity int OUT AS INSERT INTO Categories (CategoryName) VALUES(@CategoryName) SET @Identity = SCOPE_IDENTITY() RETURN @@ROWCOUNT You write the following code segment. SqlDataAdapter adapter = new SqlDataAdapter("SELECT categoryID, CategoryName FROM dbo.Categories",connection); adapter.InsertCommand = new SqlCommand("dbo.InsertCategory", connection); adapter.InsertCommand.CommandType = commandType.StoredProcedure; adapter.InsertCommand.Parameters.Add(new SqlParameter("@CategoryName", SqlDbType.NVarChar, 15,"CategoryName")); You need to retrieve the identity value for the newly created record. Which code segment should you add?

Options

  • ASqlParameter parameter =
  • BSqlParameter parameter =
  • CSqlParameter parameter =
  • DSqlParameter parameter =

How the community answered

(69 responses)
  • A
    6% (4)
  • B
    12% (8)
  • C
    80% (55)
  • D
    3% (2)

Community Discussion

No community discussion yet for this question.

Full 70-516 Practice