GIAC GIAC Secure Software Programmer - C#.NET GSSP-.NET Question # 4 Topic 1 Discussion

GIAC GIAC Secure Software Programmer - C#.NET GSSP-.NET Question # 4 Topic 1 Discussion

GSSP-.NET Exam Topic 1 Question 4 Discussion:
Question #: 4
Topic #: 1

John works as a Web Developer for ABC Inc. He develops an ASP.NET application, named MyApp1, using Visual Studio .NET. MyApp1 uses a Microsoft SQL Server 2000 database, named Database1. Database1 contains a table, named Orders, that stores the order details. In Database1, he creates a stored procedure, named Proc1, as follows:

CREATE PROCEDURE [Proc1] AS

Return (Select Count(*) from Orders)

The Proc1 stored procedure returns a count of the number of rows in the Orders table. MyApp1 includes a page, named Page1.aspx. In the Page1_Load event handler, John writes the following code to call the stored procedure:

string Str1;

SqlConnection Con;

SqlCommand Cmd1;

Str1 = "Server=TestPro1;Database=Database1;uid=sa;pwd=;";

Con = new SqlConnection(Str1);

Cmd1 = new SqlCommand("Proc1", Con);

Cmd1.CommandType = CommandType.StoredProcedure;

John wants to create an instance of the SqlParameter class that represents the return value from the Proc1 stored procedure. Which of the following code will he use to accomplish the task?


A.

SqlParameter Parm1;

Parm1 = Cmd1.Parameters.Add("@NoOfOrders", SqlDbType.Int);

Parm1.Direction = ParameterDirection.InputOutput;


B.

SqlParameter Parm1;

Parm1 = Cmd1.Parameters.Add("@NoOfOrders", SqlDbType.Int);

Parm1.Direction = ParameterDirection.Output;


C.

SqlParameter Parm1;

Parm1 = Cmd1.Parameters.Add("@NoOfOrders", SqlDbType.Int);

Parm1.Direction = ParameterDirection.ReturnValue;


D.

SqlParameter Parm1;

Parm1 = Cmd1.Parameters.Add("@NoOfOrders", SqlDbType.Int);


Get Premium GSSP-.NET Questions

Contribute your Thoughts:


Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.