Creating Connections

In the previous chapter, we created a Connection object by using the DataAdapter Configuration Wizard. The Data Form Wizard, accessed by clicking Add Windows Form on the Project menu, also creates a Connection automatically. In this chapter, we'll look at several other methods for creating Connections in Microsoft Visual Studio .NET.

Design Time Connections

Visual Studio's Server Explorer provides the ability, at design time, to view and maintain connections to a number of different system services, including event logs, message queues, and, most important for our purposes, data connections.

Important If you have not yet installed this book's practice files, work through 'Installing and Using the Practice Files' in the Introduction and then return to this chapter.

Add a Design Time Connection to the Server Explorer

1. Open the Connection project from the Visual Studio start page or from the Project menu.

2. Double-click ConnectionProperties.vb (or ConnectionProperties.cs, if you're using C#) in the Solution Explorer to open the form.

Visual Studio displays the form in the form designer.

jyH Ji*n PlMCl GSM E.'fC-jj t'JfM Tj/rnmt ^idii Jib

zl

* ■:

2

T: Hmlrvr

'J hi

WnlBri'uir Und

n

Jm^yOkJm.,

r ■■ - - - ■

U/W.W- räm 1

UfQ^g, Pti-Jl

B

1H

J

«ISm.IBL-

3. Open the Server Explorer.

4. Click the Connect to Database button.

Visual Studio displays the Data Link Properties dialog box. Tip You can also display the Data Link Properties dialog box by choosing

Connect to Database on the Tools menu.

Dat* Link Properties

Protei Corrwc&n j towiced | Al

Scectfy Ihe lollwino tc connect to SQL Ser/er data: i. Select oi enler a server name:

2 Fnlfi in'aiirdtirvi (ü löij on to Ihe sirvii

C Use Windows N T Negated secwky <* ¡Jse 4 specific usei name and passwwd: User ¡janne:

Refresh password: |

I" fiiank passivorci P ^llow^aviispii sword H ** Select (he dalabase or the seiver:

Was this article helpful?

0 0

Post a comment