Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Creating SSIS OLE DB Source with Parameters programmatically with .NET

Creating SSIS OLE DB Source with Parameters programmatically with .NET

Scheduled Pinned Locked Moved Database
csharpdatabasesql-servercomtutorial
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Dr Miroslav Stimac
    wrote on last edited by
    #1

    Hello, I am trying to build a SSIS Package programmatically with .NET (C#). Now I have problems with the component "OLE DB Source" when trying to set the ParameterMapping in order to use variables in the data flow task.

    ...
    string srcSql = "SELECT bla bla from ABC where YY = ? and BB = ? ";
    Source.SetComponentProperty("AccessMode", 2);
    Source.SetComponentProperty("SqlCommand", srcSql );

    Guid ParamGuid = new Guid(TrackingIDOld.ID);
    Guid ParamGuid1 = new Guid(TrackingIDNew.ID);

    // Here I am trying to set the parameters. However, it does not work!
    Source.SetComponentProperty("Parameter0 Name", ParamGuid.ToString());
    Source.SetComponentProperty("Parameter1 Name", ParamGuid1.ToString());

    Source.AcquireConnections(null);
    Source.ReinitializeMetaData();
    ...

    Alternatively, I also tried this, but it does not work, too:

    Source.SetComponentProperty("ParameterMapping", "User::TrackingIDOLD"); // Parameter 0
    Source.SetComponentProperty("ParameterMapping", "User::TrackingIDNew"); // Parameter 1

    Does somebody know the correct syntax how to set the parameters? Thanks for any advices! Best wishes, Miroslav Stimac

    P 1 Reply Last reply
    0
    • D Dr Miroslav Stimac

      Hello, I am trying to build a SSIS Package programmatically with .NET (C#). Now I have problems with the component "OLE DB Source" when trying to set the ParameterMapping in order to use variables in the data flow task.

      ...
      string srcSql = "SELECT bla bla from ABC where YY = ? and BB = ? ";
      Source.SetComponentProperty("AccessMode", 2);
      Source.SetComponentProperty("SqlCommand", srcSql );

      Guid ParamGuid = new Guid(TrackingIDOld.ID);
      Guid ParamGuid1 = new Guid(TrackingIDNew.ID);

      // Here I am trying to set the parameters. However, it does not work!
      Source.SetComponentProperty("Parameter0 Name", ParamGuid.ToString());
      Source.SetComponentProperty("Parameter1 Name", ParamGuid1.ToString());

      Source.AcquireConnections(null);
      Source.ReinitializeMetaData();
      ...

      Alternatively, I also tried this, but it does not work, too:

      Source.SetComponentProperty("ParameterMapping", "User::TrackingIDOLD"); // Parameter 0
      Source.SetComponentProperty("ParameterMapping", "User::TrackingIDNew"); // Parameter 1

      Does somebody know the correct syntax how to set the parameters? Thanks for any advices! Best wishes, Miroslav Stimac

      P Offline
      P Offline
      PIEBALDconsult
      wrote on last edited by
      #2

      I assume you're using some sort of API, but you don't say, so how are we to help you? Alternatively, I know people who use a product called Mist and its BIML language for generating SSIS packages. (I've never used it, I prefer to do it the hard way.)

      D 1 Reply Last reply
      0
      • P PIEBALDconsult

        I assume you're using some sort of API, but you don't say, so how are we to help you? Alternatively, I know people who use a product called Mist and its BIML language for generating SSIS packages. (I've never used it, I prefer to do it the hard way.)

        D Offline
        D Offline
        Dr Miroslav Stimac
        wrote on last edited by
        #3

        Hello, Yes, you are right. I am using an API. It is the namespace Microsoft.SqlServer.Dts.Pipeline.Wrapper See here: https://msdn.microsoft.com/en-us/library/microsoft.sqlserver.dts.pipeline.wrapper(v=sql.110).aspx[^] Especially the method SetComponentProperty: https://msdn.microsoft.com/en-us/library/microsoft.sqlserver.dts.pipeline.wrapper.cmanagedcomponentwrapperclass.setcomponentproperty(v=sql.110).aspx[^]

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups