|
Data Presentation Using the DataGrid Control |
|||
| The Wizards of Chapter 20 | |||
|
It almost sounds like it could be a Harry Potter book! The first "wizard" is really just one of the many tools available in Visual Studio, but one that is key to working with databases: Server Explorer. The book takes you directly into the specific task of establishing a data connection to the sample Access database and doesn't even mention the many other options available in Server Explorer! That's like taking a kid into a toy store exclusively for the toy trains and trying to ignore everything else in the store! If you're like me, you have to look around a bit. Although Server Explorer is just one of the windows available under the View menu, it consolidates tools and wizards that used to be scattered across a dozen tools, or not available at all, into one place. So it's worth taking a second look. Server Explorer is a "consolidation" tool in Visual Studio .NET. That means that it groups a lot of functions that are available in Windows and various other software tools into one place. This is a major new feature of Visual Studio .NET that many programmers just haven't learned about but that has value that goes well beyond just writing Visual Basic code. For example, compare the "Services" view you get in Server Explorer versus the one that is available in Windows XP Control Panel Administrative Tools: (Click on the graphic to view at full size.) Much of the information available here is more complete and detailed than you can find in Control Panel. In fact, even if you're not writing a program, you might want to check the detailed messages in the Event Logs to monitor and diagnose your computer's operation. And you can write programs using much of this information too. Here's another example, there are pages of different Performance Counters that report every aspect of your computer's operation that you can imagine. You can add them to a Visual Basic project by dragging and dropping them on a form much like the Data Adapter and Connection components that we've been working with. After a Performance Counter has been added, you can collect samples of the information reported back very simply. Here's the code to report the point value of the 'read' speed of a hard drive after filling the DataGrid as shown in our text book. (The parameter passed to the ToString method is "N zero" - this formats the number as a numeric with no decimal places.) The Data Adapter Configuration Wizard demonstrated in the book makes it easy to create the code you need to read a database, but where is that code? The only code we wrote were the Clear and Fill method calls (as shown in the code above). We briefly looked at the answer back in Chapter 5. It's in the (normally hidden) Region code at the top of the program. To fully understand what the wizard here does for you, it helps to just take a quick look at the code that is added into the Region. Just click on the plus sign at the left. But be careful not to change anything unless you really understand what you're doing. |
|||


