Creating a Custom Connection Manager
新建日期: 2006 年 4 月 14 日
The steps that you must follow to create a custom connection manager are similar to the steps for creating any other custom object for Integration Services:
- Create a new class that inherits from the base class. For a connection manager, the base class is ConnectionManagerBase.
- Apply the attribute that identifies the type of object to the class. For a connection manager, the attribute is DtsConnectionAttribute.
- Override the implementation of the methods and properties of the base class. For a connection manager, these include the ConnectionString property and the AcquireConnection and ReleaseConnection methods.
- Optionally, develop a custom user interface. For a connection manager, this requires a class that implements the IDtsConnectionManagerUI interface.
For working samples of custom connection managers, see Sql Server 自定义连接管理器示例 and Excel2 自定义连接管理器示例. The code examples shown in this topic are drawn from the Sql Server Custom Connection Manager sample.
Getting Started with a Custom Connection Manager
Creating Projects and Classes
Because all managed connection managers derive from the ConnectionManagerBase base class, the first step when you create a custom connection manager is to create a class library project in your preferred managed programming language and create a class that inherits from the base class. In this derived class, you will override the methods and properties of the base class to implement your custom functionality.
In the same solution, create a second class library project for the custom user interface. A separate assembly for the user interface is recommended for ease of deployment because it lets you update and redeploy the connection manager or its user interface independently.
Configure both projects to sign the assemblies that will be generated at build time by using a strong name key file.
Applying the DtsConnection Attribute
Apply the DtsConnectionAttribute attribute to the class that you have created to identify it as a connection manager. This attribute provides design-time information such as the name, description, and connection type of the connection manager. The ConnectionType and Description properties correspond to the Type and Description columns displayed in the Add SSIS Connection Manager dialog box, which is displayed when configuring connections for a package in Business Intelligence Development Studio.
Use the UITypeName property to link the connection manager to its custom user interface. To obtain the public key token that is required for this property, you an use sn.exe -t to display the public key token from the key pair (.snk) file that you intend to use to sign the user interface assembly.
<DtsConnection(ConnectionType:="SQLVB", _
DisplayName:="SqlConnectionManager (VB)", _
Description:="Connection manager for Sql Server", _
UITypeName:="SqlConnMgrUIVB.SqlConnMgrUIVB,SqlConnMgrUIVB,Version=1.0.0.0,Culture=neutral,PublicKeyToken=<insert public key token here>")> _
Public Class SqlConnMgrVB
Inherits ConnectionManagerBase
. . .
End Class
[DtsConnection(ConnectionType = "SQLCS",
DisplayName = "SqlConnectionManager (CS)",
Description = "Connection manager for Sql Server",
UITypeName = "SqlConnMgrUICS.SqlConnMgrUICS,SqlConnMgrUICS,Version=1.0.0.0,Culture=neutral,PublicKeyToken=<insert public key token here>")]
public class SqlConnMgrCS :
ConnectionManagerBase
{
. . .
}
Building, Deploying, and Debugging a Custom Connection Manager
The steps for building, deploying, and debugging a custom connection manager in Integration Services are similar to the steps for other types of custom objects. For more information, see Building, Deploying, and Debugging Custom Objects.
请参阅
任务
Coding a Custom Connection Manager
Developing a User Interface for a Custom Connection Manager