How to use the Server Explorer in Visual Studio .NET and Visual Studio 2005 (316649)



The information in this article applies to:

  • Microsoft Visual Studio .NET (2002), Professional Edition
  • Microsoft Visual Studio .NET (2003), Professional Edition
  • Microsoft Visual Studio 2005 Professional Edition
  • Microsoft Visual Studio 2005 Standard Edition

This article was previously published under Q316649

SUMMARY

This article explains how to use the Server Explorer in Microsoft Visual Studio .NET or in Microsoft Visual Studio 2005.

back to the top

Requirements

The following list outlines the recommended hardware, software, network infrastructure, and service packs that you need:
  • Visual Studio .NET or Visual Studio 2005
This article assumes that you are familiar with the following topics:
  • Visual Studio .NET or Visual Studio 2005
  • Microsoft Visual Basic .NET, Microsoft Visual Basic 2005, Microsoft Visual C# 2005, or Microsoft Visual C# .NET
back to the top

Visual Studio .NET or Visual Studio 2005 Server Explorer

The Server Explorer is a new development tool in Visual Studio .NET or in Visual Studio 2005 that is shared across development languages and projects. With the Server Explorer, you can connect to servers, as well as view and access their resources. For example, you can connect to, view and access the following resources:
  • Database Connections
  • Servers
  • Crystal Reports
  • Event Logs
  • Message Queues
  • Performance Counters
  • Windows Services
back to the top

Open and view Server Explorer

  1. Start Visual Studio .NET or Visual Studio 2005.
  2. Use either Visual Basic .NET, Visual Basic 2005, Visual C# 2005, or Visual C# .NET to create a new Windows Application.
  3. On the View menu, click Server Explorer. In Visual Studio 2005, click Other Windows, and then click Server Explorer. The Server Explorer window displays server resources in a tree view, which includes the following top-level nodes:
    • Data Connections
    • Servers
  4. Click to expand the Data Connections node.

    This node lists the data connections to database servers that are currently available for use. You can create connections to Microsoft SQL Server that run on Microsoft Windows, or you can create Oracle databases that run on UNIX. Data connections may not appear in this node yet, depending on how your computer is configured.
  5. Click to expand the top-level Servers node.

    This node lists the servers that are currently available for use. Each server node lists the databases and the server resources that you can use in your applications.
back to the top

Add a data connection

  1. In the Server Explorer window, right-click the Data Connections node, and then click Add Connection.
  2. In the Data Link Properties dialog box, type or select a server name in the combo box. For example, if SQL Server is installed on the local computer, type local.

    Note In Visual Studio 2005, the Add Connection dialog box appears.
  3. Type the logon information as necessary for your environment.
  4. Select a database to use. For example, if the connection is to a SQL Server, you can click Northwind.
  5. Click Test Connection to verify that the data connection is valid. After a few seconds, the following message appears:
    Test connection succeeded
    If you encounter an error during this test, check the settings, and make any necessary changes.
  6. Click OK.

    Notice that the new data connection appears as a child node below the Data Connections node.
  7. Click to expand the data connection node that you just created.

    Notice that Server Explorer displays the tables, the views, and the stored procedures that are available to you from this server.
back to the top

Add a server

  1. In the Server Explorer window, right-click the Servers node, and then click Add Server.
  2. In the Add Server dialog box, type a server name that differs from your local server, or type an IP address that differs from your Internet Protocol (IP) address.
  3. If you use a different user name to log on to the server, click Connect using a different user name, and then type your user name and password.
  4. Click OK.

    Notice that a new server node appears below the top-level Servers node.
  5. Click to expand the server node that you just created.

    Server Explorer displays the resources that are available to you, such as Crystal Services, Event Logs, Message Queues, Performance Counters, Services and SQL Servers. You receive the same information for your local computer when you click to expand your local server name.
back to the top

Drag a connection from Server Explorer to your form

You can use the drag-and-drop method to copy almost any object from the Server Explorer into the Visual Studio .NET designers. The integrated development environment (IDE) automatically creates a pre-configured object that you can use in your application.

This ability to copy objects provides a powerful tool for rapid application development (RAD) programming. For example, when you drag a data connection onto a form, Visual Studio .NET creates a connection object that does not require you to provide any code.

To use the drag-and-drop method to create a new connection, follow these steps:
  1. In the Server Explorer window, select the data connection that you created, and then switch to Form Designer.
  2. Drag the data connection from the Server Explorer to Form1. Visual Studio .NET automatically creates a SQLConnection object with the ConnectionString, the Database, and the DataSource properties already set.
You can now run your code and use the SQLConnection.

Note Visual Studio 2005 does not support this drag-and-drop method in Server Explorer

back to the top

Verify that the connection works

After you add a data connection, a new node appears under the top-level Data Connections node. You should be able to browse through the server tables, the views, and the stored procedures.

After you add a server, a new node appears under the top-level Servers node. You should be able to browse through the server to see its resources, such as Event Logs, Message Queues, and Performance Counters.

After you drag and drop the Data Connection onto Form1, a SQLConnection object that is named SQLConnection1 (in Visual Basic .NET or Visual Basic 2005) or sqlConnection1 (in Visual C# .NET or in Visual C# 2005) appears in the Component list.

back to the top

Troubleshooting

This article uses settings that are specific to the system configuration. You must use the server names, the database names, the logon names, and the passwords that are appropriate to your system.

back to the top

REFERENCES

For more information, visit the following Microsoft Developer Network (MSDN) Web site: back to the top

Modification Type:MinorLast Reviewed:5/2/2006
Keywords:kbvs2005swept kbvs2005applies kbHOWTOmaster KB316649 kbAudDeveloper