What code segment should you add for the PowerTools.vb code-behind page?

You are developing a product page named Category.aspx for Web application that will be integrated into Domain.com’s existing e-Commerce Web site. The Category.aspx page accesses data from the CKProducts database. You use a stored procedure named sp_GetProductsByCategory to display data in a GridView control named _gridView. The stored procedure is shown in the following exhibit.

The Category.aspx page displays products belonging to a particular category that the customers select. The category is passed as a parameter from a DropDownList control.
You want to create a PowerTools.aspx page that displays all power tools in the CKProducts database. The CategoryID for power tools is listed as 102 in the CKProducts database. You want to use a SqlCommand instance to execute the sp_GetProductsByCategory stored procedure to return the appropriate data from the CKProducts database.
exhibit What code segment should you add for the PowerTools.vb code-behind page?

You are developing a product page named Category.aspx for Web application that will be integrated into Domain.com’s existing e-Commerce Web site. The Category.aspx page accesses data from the CKProducts database. You use a stored procedure named sp_GetProductsByCategory to display data in a GridView control named _gridView. The stored procedure is shown in the following exhibit.

The Category.aspx page displays products belonging to a particular category that the customers select. The category is passed as a parameter from a DropDownList control.
You want to create a PowerTools.aspx page that displays all power tools in the CKProducts database. The CategoryID for power tools is listed as 102 in the CKProducts database. You want to use a SqlCommand instance to execute the sp_GetProductsByCategory stored procedure to return the appropriate data from the CKProducts database.
What code segment should you add for the PowerTools.vb code-behind page?

A.
SqlParameter paraCategory = command.Parameters.AddWithValue(“CategoryID”,102); command.ExecuteNonQuery();

B.
SqlParameter paraCategory = command.Parameters.AddWithValue(“@CategoryID”,102); SqlDataReader dataReader = command.ExecuteReader();

C.
SqlParameter paraCategory = new SqlParameter(“CategoryID”, SqlDbType.Int); paraCategory.Direction = ParamerterDirection.Output; paraCategory.Value = 102;
command.ExecuteNonQuery();

D.
SqlParameter paraCategory = new SqlParameter(“@CategoryID”, SqlDbType.Int); paraCategory.Direction = ParamerterDirection.Output; paraCategory.Value = 102;
SqlDataReader dataReader = command.ExecuteReader(); Seite 89 von 144
BRAINDUMPS – ASP.NET

Explanation:
You need to declare the @CategoryID input parameter with a value of 102 that must be passed to the stored procedure. You must then call the ExecuteReader method of the SqlCommand class to return the results.

Incorrect Answers:
A: This code declares a CategoryID input parameter but the stored procedure only accepts a @CategoryID parameter. This code also calls the ExecuteNonQuery method of the SqlCommand class. The ExecuteNonQuery method of the SqlCommand class does not return data.
C: This code creates an output parameter. However, you need a parameter to pass a parameter to the stored procedure. Input parameters are passed to a stored procedure. This code also calls the ExecuteNonQuery method of the SqlCommand class. The ExecuteNonQuery method of the SqlCommand class does not return data.
D: This code creates an output parameter. However, you need a parameter to pass a parameter to the stored procedure. Input parameters are passed to a stored procedure.



Leave a Reply 0

Your email address will not be published. Required fields are marked *