ASP.NET Versions: 1.0 | 1.1
Visual Studio .NET Server Explorer
Discover the power and convenience that this RAD tool can provide.
By Ken McNamee
As one of the most useful tools in Visual Studio .NET, the Server Explorer provides an enormous amount of information, design-time convenience, and run-time functionality. In fact, the Server Explorer is actually several tools in one. At its simplest level, it allows you to explore entities such as Event Log entries and database objects. The next level allows you to manage the server by starting and stopping Windows Services, creating database objects, and even changing data. The most advanced level of the Server Explorer provides the developer with programmatic access to some of the objects such as Event Logs, Performance Counters, Message Queues, Windows Services, and database tables, views, and stored procedures.
Any description of the Server Explorer has to begin with its database management and programming capabilities, which can duplicate the features of SQL Server Enterprise Manager and Query Analyzer - almost. Server Explorer allows you to graphically create databases, tables, views, and stored procedures completely from within Visual Studio .NET. You can also edit and delete existing database objects. However, these management features pale in comparison to the power and convenience of its other features. For example, you can drag and drop a table from the Server Explorer onto a Web Form design surface and a slew of ADO.NET objects and code is created for you to enable programming against that table. A SqlConnection and SqlDataAdapter object are inserted into the code and SQL statements are generated for selecting, inserting, updating, and deleting from that table.
Drag a stored procedure onto a Web Form and a SqlCommand object is generated along with all the ADO.NET code necessary to call the stored procedure. This feature can be a real timesaver since typing in the code for possibly dozens of SqlParameter objects can be a tedious and - more importantly - error-prone task.
Like Enterprise Manager and Query Analyzer, Server Explorer also allows you to retrieve all the data from a table and display it in an editable grid. You can also generate a "create script" for any of the database objects and even create a database diagram. However, one of the most convenient aspects of these features is that almost all the windows that are generated appear as normal Visual Studio .NET tabbed windows. This makes it very easy to integrate the features of the tool with the rest of your development and switch between code-behind for a Web Form, a stored procedure creation script, and a table design window without having to switch development environments.
Figure 1. The Visual Studio .NET Server Explorer allows developers to view Event Logs, manage Windows Services and SQL Server databases, and even drag resources such as Performance Counters and database tables onto Web Forms.
Counters, Queues, and Logs
SQL Server database objects aren't the only items that can be dragged off the Server Explorer and dropped onto a Web Form. Performance counters, message queues, and event logs can also be dragged and dropped to create PerformanceCounter, MessageQueue, and EvenLog objects - respectively - in your code-behind. These objects can then be programmed against to add some professional touches to your code with a minimal amount of effort. Message queues in particular can be used to significantly increase the scalability of your Web applications. Dragging and dropping a specific public or private message queue onto your Web form automatically inserts all the necessary initialization code and property assignments so that you can worry less about the plumbing and more about your logic.
I've grown to depend on the convenience that the Server Explorer provides. It may not always create the most efficient code, especially for database operations. However, what it does provide is always at least a good place to start. Many times I will drag a table onto a form just to get some of the SQL statements that it generates - even if I have no intention of using the object (which I then delete).
There is also no better place to explore the myriad performance counters at your disposal. If you've ever been frustrated by the System Monitor administrative tool just to see what performance counters were available, you'll be pleasantly surprised by the tree view interface in the Server Explorer. Depending on what you have installed on your system, you may also see other options in the Server Explorer such as Crystal Services, which allows you to drag and drop Crystal Reports objects onto your forms for programmatic access.
The Server Explorer is one of the best examples of the rapid application development features in Visual Studio .NET. It is easy to use, provides a significant amount of functionality, and requires almost no learning curve to get started. You may find that you have no use for most of its features, but I bet you'll get hooked on at least one and find yourself using it over and over again.
Ken McNamee is a Senior Software Developer with Vertigo Software, Inc., a leading provider of software development and consulting services on the Microsoft platform. Prior to this he led a team of developers in re-architecting the Home Shopping Network's e-commerce site, HSN.com, to 100% ASP.NET with C#. Readers can contact him at [email protected].