Editare

Partajați prin


IDataEnvironment.ConfigureConnection Method

Definition

Writes a connection string to the application's configuration file.

public:
 System::ComponentModel::Design::Data::DesignerDataConnection ^ ConfigureConnection(System::Windows::Forms::IWin32Window ^ owner, System::ComponentModel::Design::Data::DesignerDataConnection ^ connection, System::String ^ name);
public System.ComponentModel.Design.Data.DesignerDataConnection ConfigureConnection (System.Windows.Forms.IWin32Window owner, System.ComponentModel.Design.Data.DesignerDataConnection connection, string name);
abstract member ConfigureConnection : System.Windows.Forms.IWin32Window * System.ComponentModel.Design.Data.DesignerDataConnection * string -> System.ComponentModel.Design.Data.DesignerDataConnection
Public Function ConfigureConnection (owner As IWin32Window, connection As DesignerDataConnection, name As String) As DesignerDataConnection

Parameters

owner
IWin32Window

The parent window for the dialog, if any.

connection
DesignerDataConnection

A DesignerDataConnection object containing the connection data to save.

name
String

The name of the new connection configuration entry.

Returns

A DesignerDataConnection object containing the saved connection data with the Name property set to name, and the IsConfigured property set to true.

Remarks

The ConfigureConnection method writes a connection to the application's configuration file. The connection string and provider name are written to the connectionStrings Element (ASP.NET Settings Schema) configuration element named according to the name parameter. The Name property of the connection parameter is ignored.

Implementations of the ConfigureConnection method should throw the following exceptions.

Exception Reason
ArgumentException A duplicate name exists in the application's configuration file.
FileNotFoundException, UnauthorizedAccessException, or other appropriate file IO exception. The application's configuration file cannot be updated. Your ConfigureConnection method implementation should throw an appropriate exception.
CheckoutException The application's configuration file cannot be checked out from the source control system.

Consider using the configuration-management APIs in the System.Configuration namespace to read and write the application's configuration file. The ConnectionStringsSection class will read and write the connectionStrings Element (ASP.NET Settings Schema) configuration element.

Applies to