Megosztás a következőn keresztül:


How to: Edit a Connection String

Connection strings stored in an application are either saved in the application configuration file (application settings) or compiled in the code (typically as the ConnectionString property of a connection object). Data connections created with the Data Source Configuration Wizard give you the option to store connection strings in the applications settings file, or to hard-code them in the dataset definition.

Editing Connection Strings Stored in Application Settings

You can modify connection information that is saved in application settings by using the Project Designer.

To edit a connection string stored in application settings

  1. In Solution Explorer, double-click the My Project icon (Visual Basic) or Properties icon (Visual C#) to open the Project Designer.

  2. Select the Settings tab.

  3. Locate the connection you want to edit and select the text in the Value box.

  4. Edit the connection string in the Value box.

    -or-

    Click the ellipses in the Value box to edit your connection with the Connection Properties dialog box. For more information, see Add/Modify Connection Dialog Box (General).

Editing Hard-Coded Connection Strings

You can modify connection information that is saved in code by using the Dataset Designer.

To edit a connection string stored in code

  1. In Solution Explorer, double-click the dataset (.xsd file) with the connection you want to edit.

  2. Select the TableAdapter or query with the connection you want to edit.

  3. In the Properties window expand the DefaultConnection node.

  4. To quickly modify the connection string, edit the ConnectionString property.

    -or-

    Click the down arrow on the DefaultConnection property and choose New Connection to open the Add/Modify Connection Dialog Box (General).

Security

Storing sensitive information (such as a password) can affect the security of your application. Using Windows Authentication (also known as integrated security) is a more secure way to control access to a database. For more information, see Protecting Connection Information (ADO.NET).

See Also

Concepts

Displaying Data Overview

Reference

SqlConnection.ConnectionString

OleDbConnection.ConnectionString

Other Resources

Connecting to Data in Visual Studio

Preparing Your Application to Receive Data

Fetching Data into Your Application

Displaying Data on Forms in Windows Applications

Editing Data in Your Application

Validating Data

Saving Data