Question: Extra 15-1 Add a parameterized query to the Product Maintenance form in VISUAL BASIC Open the ProductMaintenance project in the ProductMaintenance directory. Then, increase the

Extra 15-1 Add a parameterized query to the Product Maintenance form in VISUAL BASIC

Open the ProductMaintenance project in the ProductMaintenance directory. Then, increase the height of the form and move the controls on the form down to make room for another Toolstrip control.

Use the smart tag menu for one of the bound controls to add a parameterized query named FillByProductCode that will retrieve the row for a product with the specified product code. Add an If statement to the Try block that was generated that checks the Count property of the binding source to be sure that the product is found. If its not found, an error message should be displayed. Test the application to be sure this works.

Display the Items Collection editor for the Toolstrip control you just created. Then, modify the control so it appears as shown above.

Create an event handler for the Click event of the Get All Products button. Then, copy the statement in the Load event handler for the form that loads data into the Products table to the Click event handler, and delete the Load event handler so no data is loaded when the application starts. Test the application to see how this works.

Add an Imports statement for the System.Data.SqlClient namespace to the form. Then, add a TryCatch statement to the Click event handler you just created that catches any SQL exceptions that occur. If an exception occurs, the catch block should display the exception number and message in a dialog box whose caption is the type of exception.

Format the Unit Price text box so the data it contains is displayed as currency with two decimal places. Then, test the application one more time.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!