System.ComponentModel.Design.Data.IDataEnvironment.BuildConnection Method

Creates a new data connection or edits an existing connection using the design tool's new connection user interface.

Syntax

public DesignerDataConnection BuildConnection (System.Windows.Forms.IWin32Window owner, DesignerDataConnection initialConnection)

Parameters

owner
The parent window for the connection dialog.
initialConnection
The connection, if any, to edit. To create a new connection, initialConnection should be null.

Returns

A new or edited System.ComponentModel.Design.Data.DesignerDataConnection object, or null if the user canceled.

Remarks

Use the IDataEnvironment.BuildConnection(System.Windows.Forms.IWin32Window, DesignerDataConnection) method to activate the design environment's user interface for creating or editing data connections. If the initialConnection parameter is null, it indicates the user wants to create a new connection. If the initialConnection parameter is a System.ComponentModel.Design.Data.DesignerDataConnection object, it indicates the user wants to edit an existing connection.

Your design environment is responsible for creating the data connection, adding the connection either to a global list of connections or to the Web application's configuration file, and adding the new connection to the IDataEnvironment.Connections property.

The new connection should include the information that the application needs to create a data connection at run time. If you need to use the data connection in the design environment, use the IDataEnvironment.GetDesignTimeConnection(DesignerDataConnection) method to return a System.Data.Common.DbConnection object that will connect to the data store from the design environment.

If the user chooses to cancel the new connection creation process, the IDataEnvironment.BuildConnection(System.Windows.Forms.IWin32Window, DesignerDataConnection) method should return null.

Requirements

Namespace: System.ComponentModel.Design.Data
Assembly: System.Design (in System.Design.dll)
Assembly Versions: 2.0.0.0