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:
back to the top Visual Studio .NET or Visual Studio 2005 Server Explorer
- Visual Studio .NET or Visual Studio 2005
- Microsoft Visual Basic .NET, Microsoft Visual Basic 2005, Microsoft Visual C# 2005, or Microsoft Visual C# .NET
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:
back to the top Open and view Server Explorer
- Database Connections
- Crystal Reports
- Event Logs
- Message Queues
- Performance Counters
- Windows Services
back to the top Add a data connection
- 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 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 server
- In the Server Explorer window, right-click the Data Connections node, and then click Add Connection.
- 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.
- Type the logon information as necessary for your environment.
- 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:
Test connection succeeded If you encounter an error during this test, check the settings, and make any necessary changes.
- Click OK.
Notice that the new data connection appears as a child node below the Data Connections node.
- 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 Drag a connection from Server Explorer to your form
- 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 node.
- 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.
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:
- 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 Server Explorerback 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 back to the top