Export (0) Print
Expand All

Sql Server Custom Connection Manager Sample

SQL Server 2005

Updated: 14 April 2006

The SQL Server Custom Connection Manager sample demonstrates how to create a custom connection manager, the Sql Connection Manager, and its associated user interface. This sample is not supported on Itanium-based operating systems.

For more information about creating a custom connection manager, see Creating a Custom Connection Manager. For general information about the use of connection managers in Integration Services, see Integration Services Connections and Connection Managers.

This custom connection manager connects to an available instance of Microsoft SQL Server by using the SqlClient .NET Framework Data Provider, and returns an open SqlConnection object from its AcquireConnection method. When you create a new instance of the Sql Connection Manager in a package, its custom user interface prompts you for the server name and a database name. The sample connects only to a default instance of SQL Server, and uses only Windows Authentication.

This code sample implements the following functionality:

ms345276.note(en-US,SQL.90).gifImportant:
Samples are provided for educational purposes only. They are not intended to be used in a production environment and have not been tested in a production environment. Microsoft does not provide technical support for these samples.

If you already know how to locate, build, and install code samples, you can go directly to the section Testing the Sample, and read about how to configure and run the code sample

This sample requires that the following components are installed.

  • Microsoft Visual Studio 2005
  • Microsoft SQL Server 2005 Integration Services

If the code sample was installed to the default location, the sample is located in the following directory:

C:\Program Files\Microsoft SQL Server\100\Samples\Integration Services\\Programming Samples\Control Flow\SqlConnectionManager Sample

The C# solution for the code sample is located in the SqlConnMgrCS directory, and the Visual Basic solution is located in the SqlConnMgrVB directory.

For information about the two-step process required to install the samples, see Installing Samples. To obtain the latest version of the samples, including new samples released after the original release of SQL Server 2005, see SQL Server 2005 Samples and Sample Databases (April 2006).

If you have not already generated a strong name key file in the Samples folder, use the following procedure to generate this key file. The sample projects are configured on the Signing tab of the Project Properties dialog box to sign assemblies at build time with this key file.

  1. To open a Microsoft Visual Studio 2005 command prompt, click Start, point to All Programs, point to Microsoft Visual Studio 2005, point to Visual Studio Tools, and then click Visual Studio 2005 Command Prompt.

    - or -

    To open a Microsoft .NET Framework command prompt, click Start, point to All Programs, point to Microsoft .NET Framework SDK v2.0, and then click SDK Command Prompt.

  2. At the command prompt, use the change directory (CD) command to change the current folder of the Command Prompt window to the Samples folder. The key file that you create in this folder will be used by all SQL Server 2005 code samples.

    ms345276.note(en-US,SQL.90).gifNote:
    To determine the folder where samples are located, click Start, point to All Programs, point to Microsoft SQL Server 2005, point to Documentation and Tutorials, and then click Samples Directory. If the default installation location was used, the samples are located in <system_drive>:\Program Files\Microsoft SQL Server\90\Samples.

  3. At the command prompt, run the following command to generate the key file:

    sn -k SampleKey.snk
    
    
    ms345276.note(en-US,SQL.90).gifImportant:
    For more information about the strong-name key pair, see "Security Briefs: Strong Names and Security in the .NET Framework" in the .NET Development Center on MSDN.

  4. You will need the public key token from the key file in a subsequent step. To obtain the public key token, first extract the public key from the key file to a new file by running the following command at the command prompt:

    sn -p SampleKey.snk SampleKeyPublic.snk
    

    Now display the public key token from the new file by running the following command at the command prompt:

    sn -t SampleKeyPublic.snk
    

    Copy the public key token to the clipboard or save it for later use.

  1. From the File | Open menu, click Project and open the solution file SqlConnMgrVB.sln or SqlConnMgrCS.sln.

  2. In the Solution Explorer, select the SqlConnMgrVB or SqlConnMgrCS project.

  3. Locate the DtsConnection attribute before the class declaration in the SqlConnMgrCS.cs file or the SqlConnMgrVB.vb file and replace the alphanumeric value of the Public Key Token in the UITypeName property of the attribute with the public key token obtained earlier from the key file.

  4. On the Build menu, click Build Solution.

This sample is provided in both Visual Basic and C#. To distinguish the assemblies for each version of the sample, the name of the output assembly has CS or VB appended. After successfully building the component, follow these steps in order to add it as a connection manager in a package in Business Intelligence Development Studio.

  1. Open Windows Explorer or your preferred application for working in the file system.

  2. Copy the assemblies (SqlConnMgrCS.dll and SqlConnMgrUICS.dll, or SqlConnMgrVB.dll and SqlConnMgrUIVB.dll) to the Connections folder located at %system%\Program Files\Microsoft SQL Server\90\DTS.

  1. Open Windows Explorer or your preferred application for working in the file system.

  2. Drag the assemblies from the Connections folder to the folder where the global assembly cache (GAC) is located, at %system%\assembly.

  1. Open a Command Prompt window.

  2. Type the following commands to install the C# version of the component and the user interface into the GAC:

    gacutil.exe -iF " C:\Program Files\Microsoft SQL Server\90\Samples\Integration Services\Programming Samples\Control Flow\SqlConnectionManager Sample\SqlConnMgrCS\bin\Debug\SqlConnMgrCS.dll"
    gacutil.exe -iF " C:\Program Files\Microsoft SQL Server\90\Samples\Integration Services\Programming Samples\Control Flow\SqlConnectionManager Sample\SqlConnMgrCS\bin\Debug\SqlConnMgrUICS.dll"
    

    - or -

    Type the following commands to install the Visual Basic version of the component and the user interface into the GAC:

    gacutil.exe -iF " C:\Program Files\Microsoft SQL Server\90\Samples\Integration Services\Programming Samples\Control Flow\SqlConnectionManager Sample\SqlConnMgrVB\bin\Debug\SqlConnMgrVB.dll"
    gacutil.exe -iF " C:\Program Files\Microsoft SQL Server\90\Samples\Integration Services\Programming Samples\Control Flow\SqlConnectionManager Sample\SqlConnMgrVB\bin\Debug\SqlConnMgrUIVB.dll"
    

You can now test the custom connection manager in a package.

  1. In the connection managers area of SSIS Designer, right-click, select New Connection, and in the list of available connection types, select SQL. Click OK.

  2. Edit the new connection manager. In the Sql Connection Manager Editor, provide the name of an available default instance of the SQL Server Database Engine and of an available database.

Release History

14 April 2006

Changed content:
  • Corrected file and folder names.
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft