PrepAway - Latest Free Exam Questions & Answers

Which code segment should you use?

You use Microsoft .NET Framework 4 to develop an application that connects to a Microsoft SQL
Server 2008 database. You add the following stored procedure to the database.
CREATE PROCEDURE dtao.InsertTag
BName nvarchar (15)
AS
INSERT INTO Tags (Name) VALUES(@Name)
RETURN @@ROWCOUNT
You need to invoke the stored procedure by using an open SqlConnection named conn. Which code
segment should you use?

PrepAway - Latest Free Exam Questions & Answers

A.
Dim cmd As SqlCommand =
New SqlCommand(“EXEC InsertTag”, conn)
cmd.CommandType = CommandType.Text
cmd.Parameters.AddWithValue(“eName”, “New Tag 1”)
cmd.ExecuteNonQuery()

B.
Dim cmd As SqlCommand =
New SqlCommand(“EXEC InsertTag”, conn)
cmd.CommandType = CommandType.StoredProcedure cmd.Parameters.AddWithValue(“eName”,
“New Tag 1”)
cmd.ExecuteNonQuery()

C.
Dim cmd As SqlCommand = New SqlCommand(“InsertTag”, conn)
cmd.CommandType = CommandType.Text
cmd.Parameters.AddWithValue(“BName”, “New Tag 1”)
cmd.ExecuteNonQuery()

D.
Dim cmd As SqlCommand = New SqlCommand (“InsertTag”, conn)
cmd.CommandType = CommandType. StoredProcedure
cmd. Parameters.AddllithValue (“GName”, “New Tag 1”)
cmd.ExecuteNonQuery()

Explanation:
http://msdn.microsoft.com/en-us/library/yy6y35y8(v=vs.71).aspx


Leave a Reply