Week 12

Monday Chapter 10

Page 625 Tutorial 10-1 Showing a database table in DataGridView control. Before starting the tutorial make sure you have Company.mdf file, which is located in the student programs for Chapter 10 and make sure you upload it with your homework. Otherwise, your program will crash without it. So, it must be included with your project zipped.

Also, remember after finding database, copy and paste it to your project. You have to click Save All so all the files for your project are created. If you don’t your work can get corrupted. …. Remember “File Save All”

You can put your database anywhere in the project, you just have to remember the path of your project. I usually put it in the bin folder.

Now you will be using the GUI from your Database section. So, look for Data in your toolbox window and drag the DataGridView. If it does not work, it can easily get corrupted. Just delete it and restart dragging a new DataGridView. You may have to change the location of the database location. Eg. Mine went to the SQL server’s sample file, so I had to go to MyDocuments -> Projects ŕ the project where I am working ŕ the bin where I chose to put my database. I also had to change from a different extension of files to all files so I could see the Company.mdf file I had.

You may not see the same picture as in the book in Figure 10-12, but if you click the plus sign to a minus sign, you can see SalesStaff.

So, you get an empty table. Then build and start debugging. If you cannot see the entire database, you will have to go back to your form and extend the database so that everything can be seen.