Programming Lab 4: Inventory Grid, due Thursday, 10/26
Objective: To write a program using the DataAdapter and Grid controls
Here are the details and rules:
- Write a program to allow the user to view, enter and save inventory data like shown here:
- Create the DataAdapter from the Toolbox, and use the wizard to generate stored procedures for all
the commands. The wizard will create a Connection control for you as well.
- By default in Visual Studio 2005, design-time support for data adapters has been turned off. To turn
on this support for data adapters, you must add them to the Toolbox, as described here:
To add data adapters, connections, and commands to the Toolbox Right-click the Toolbox and choose Choose
Items. Select the items you want to add from the .NET Framework Components tab of the Choose Toolbox
Items dialog box. (E.g. SqlDataAdapter, SqlConnection, and SqlCommand). Click OK to add the selected items
to the Toolbox.
- The DataGridView control available in Visual Basic 2005 can be used the same way as the DataGrid
(instead of it).
- Create the DataSet in code, not using a control from the Toolbox. Use the DataAdapter to
generate your DataSet's schema and constraints. (Don't setup all the DataColumns individually like the
last assignments.)
- Before the user clicks "Load", the grid will not display anything. After "Load" has been clicked,
the form will look like it does above (column widths may be different).
- When the user clicks, "Update", any changes, additions, or deletions in the grid will be saved to
the database.
- Your DataSet and DataGrid should enforce all the constraints from the database.
(e.g. don't allow ID to be edited, ProductName cannot be null) - the program should be able to handle
these kinds of errors without crashing.
- If the user clicks "Load" after the data has already been loaded, it should be refreshed from the
database, without generating any errors or problems.
- When turning in your homework, turn in the text of the stored procedures for your commands (which
were generated by the DataAdapter wizard) and a zip file containing your entire solution.
- For 10% Extra Credit: Make your program automatically display with the grid columns the right
size, as shown in the image above. You cannot change the fact that the DataSet has to be set in code.
(You can't use a DataSet control.) The widths should be determined at run-time based on the contents of
tblInventory.
Return to main CS 112D page