IDataEnvironment::ConfigureConnection Method (IWin32Window^, DesignerDataConnection^, String^)
Writes a connection string to the application's configuration file.
Assembly: System.Design (in System.Design.dll)
DesignerDataConnection^ ConfigureConnection( IWin32Window^ owner, DesignerDataConnection^ connection, String^ name )
Parameters
- owner
-
Type:
System.Windows.Forms::IWin32Window^
The parent window for the dialog, if any.
- connection
-
Type:
System.ComponentModel.Design.Data::DesignerDataConnection^
A DesignerDataConnection object containing the connection data to save.
- name
-
Type:
System::String^
The name of the new connection configuration entry.
Return Value
Type: System.ComponentModel.Design.Data::DesignerDataConnection^A DesignerDataConnection object containing the saved connection data with the Name property set to name, and the IsConfigured property set to true.
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 |
|---|---|
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. |
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.
Available since 2.0