This article explains how to use the Server Explorer in
Microsoft Visual Studio .NET or in Microsoft Visual Studio
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
- Visual Studio .NET or Visual Studio 2005
- Microsoft Visual Basic .NET, Microsoft Visual Basic 2005,
Microsoft Visual C# 2005, or Microsoft Visual C# .NET
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
- Crystal Reports
- Event Logs
- Message Queues
- Performance Counters
- Windows Services
Open and view Server Explorer
- Start Visual Studio .NET or Visual Studio 2005.
- Use either Visual Basic .NET, Visual Basic 2005, Visual C#
2005, or Visual C# .NET to create a new Windows Application.
- 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:
- 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.
- Click to expand the top-level Servers
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.
Add a data connection
- In the Server Explorer window, right-click the Data
Connections node, and then click Add
- 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
- Type the logon information as necessary for your
- Select a database to use. For example, if the connection is
to a SQL Server, you can click Northwind.
- Click Test Connection to verify that the
data connection is valid. After a few seconds, the following message appears:
If you encounter an
error during this test, check the settings, and make any necessary
Test connection succeeded
- Click OK.
Notice that the new
data connection appears as a child node below the Data
- Click to expand the data connection node that you just
Notice that Server Explorer displays the tables, the views,
and the stored procedures that are available to you from this server.
Add a server
- In the Server Explorer window, right-click the
Servers node, and then click Add Server.
- 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.
- 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.
- Click OK.
Notice that a new
server node appears below the top-level Servers
- 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.
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
To use the drag-and-drop method to create a new connection,
follow these steps:
- In the Server Explorer window, select the data connection
that you created, and then switch to Form Designer.
- 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
Visual Studio 2005 does not support this drag-and-drop method in
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
node. You should be able to browse through the server
to see its resources, such as Event Logs, Message Queues, and Performance
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
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.
Article ID: 316649 - Last Review: May 2, 2006 - Revision: 2.4
- 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
|kbvs2005swept kbvs2005applies kbhowtomaster KB316649|