Programming with Microsoft VB 2017 Diane Zak Chapter 11 Utilities Solution
Open the Utilities Solution.sln file contained in the VB2017\Chap11\Utilities Solution-DataGrid folder.
a. Create a SQL Server database named Utilities.mdf.
b. Add the Bills table definition shown in Figure 11-64 to the database. The Month field’s (Is Identity), Identity Increment, and Identity Seed properties are set to True, 1, and 1, respectively. (Recall that you need to expand the Identity Specification property to access these properties.)
c. After defining the table, click the Update button and then click the Update Database button.
d. Open the Data Sources window and start the Data Source Configuration Wizard. Connect the Utilities.mdf file to the application. Include the entire Bills table in the dataset.
e. Set the Utilities.mdf file’s Copy to Output Directory property to “Copy if newer”.
f. Drag the Bills table to the form. Set the DataGridView control’s AutoSizeColumnsMode property to Fill.
g. Open the DataGridView control’s task list and click Dock in Parent Container. Click Edit Columns. Change the Month column’s AutoSizeMode property to ColumnHeader.
h. Click Electricity in the Edit Columns dialog box, click DefaultCellStyle, click the … (ellipsis) button, click Format, click the … (ellipsis) button, click Numeric, and then click the OK button. The Format box now shows N2. Change the Alignment property to MiddleRight and then click the OK button to close the CellStyle Builder dialog box.
i. Now, format the Water and Gas columns using the Numeric setting with two decimal places. Also, align the values in both columns using the MiddleRight setting. When you are finished setting the properties, close the Edit Columns dialog box.
j. Change the form’s Size property to 330, 200.
k. Open the Code Editor window and enter an appropriate Try…Catch statement.
l. Save the solution and then start the application. Enter the three records shown in Figure 11-64. (Recall that the Month field is an auto-numbered field. The numbers 1, 2, and 3 will appear when you click the Save Data button.)
m. Stop the application and then start it again to verify that the three records were saved.