Welcome to MSDN Blogs Sign in | Join | Help

Using SSIS object model from C++

All the samples in MSDN show how use SSIS API from C# or VB.NET code. Is it possible to do this from C++ code? The answer is yes, if you know COM it should be quite easy for you, and the COM API is very close to .NET API (I think .NET API is nicer due to rich type system and properties).

Note that you still need to install either SSIS (if you want to execute package) or Workstation Components (if you write client tool that does not execute packages) - so you have something that implements the API you will be using :). This of course installs .NET 2.0 - so even if you don't use it, it has to be installed.

Instead of referencing .NET assemblies you will use COM interfaces, declared in DTS.H (from C:\Program Files\Microsoft SQL Server\90\SDK\Include). Here is a sample how to count the packages in SSIS server from C++. All error checking is removed for clarity, if you use this code in production - add error checking. Alternatively, you can #import <dts.dll> if you like VC com support classes - they provide automatic HRESULT-to-exception translation.

#include "dts.h"

void EnumPackages()
{
    CComPtr<IDTSApplication90> app;
    CComPtr<IDTSPackageInfos90> pkgInfos;

    app.CoCreateInstance(__uuidof(Application));
    app->GetDtsServerPackageInfos(CComBSTR(L
"File System"), CComBSTR(L"."
), &pkgInfos);

    LONG count;
    pkgInfos->get_Count(&count);

    printf("found %d packages", count);
}

int _tmain(int argc, _TCHAR* argv[])
{
    CoInitializeEx(NULL, COINIT_MULTITHREADED);

    EnumPackages();

    CoUninitialize();
    return 0;
}

Published Thursday, March 29, 2007 5:18 PM by michen
Filed under: ,

Comments

# re: Using SSIS object model from C++

Thanks Michael for the info.Helped me in getting started.

Could you give some pointers to resources where I could get addtional information on Integration services programming using C++?

Thanks again in advance.

Wednesday, May 09, 2007 7:57 AM by Advait Karnik
New Comments to this post are disabled
 
Page view tracker