DTS Package Object Model

  • Does anybody know how to retrieve the list of objects to be transfered (through theAddObjectForTransfer method) within a DTSTransferObjectsTask step? The GetObjectForTransfer method requires you know the object name, owner, and type - this is the part I don't know and want to find out.

    Anybody?

    Thanks,

    Trevor

  • This was removed by the editor as SPAM

  • Trevor,

    This might help you some.

    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dtsprog/dtsptasks_5r90.asp

    Good luck,

    Darrell

  • Thanks Darrell, but I've already been though that one. One would think that if MS included and add method, there must be another collection available.

     

    Trevor

  • ok, here it is: Its not perfect, but it works.

    This is part of my code, so let me explain.  The important stuff is highlighted.  You have to get a hold of your Task object from the particular package object that contains the TransferObjectTasks.  One bad part that I can't figure out is how many objects there are in the collection to transfer, so it loops until an index out of range exception.  Don't see any accessible collection to get a count anywhere.

    I've tried this and it works.  To filter, take a look at the DTS.DTSSQLObjectType constant list by going here: http://www.free2space.com/docs/prog/Microsoft_SQL_Server_Books_Online/6_dtsr17_12.htm

    Hope it helps, I'd be intrested to hear if this works for you.

    foreach

    (DTS.Task T in package.Tasks)

    {

    Task =

    new DTSTask();

    Task.Name = T.Name;

    Task.TaskType = T.CustomTaskID;

    if(Task.TaskType=="DTSTransferObjectsTask")

    {

    string ObjectName;

    string OwnerName;

    DTS.DTSSQLObjectType _type;

    try

    {

    for(int i=0;i<100;i++)

    {

    ((DTS.TransferObjectsTask2)T.CustomTask).GetObjectForTransfer(i,out ObjectName,out OwnerName,out _type);

    Console.WriteLine(ObjectName + " - " + OwnerName + " - " + _type.ToString());

    }

    }

    catch(System.Runtime.InteropServices.COMException ioex)

    {

    Console.WriteLine("No more objects");

    }

    }

    Task.Description = T.Description;

     

    Paul K


    Kindest Regards,

    Paul Krasucki, MCAD

  • It took a lot of effort to rewrite my app from VB.Net to C# so I could use the example Paul supplied above, but it worked like a charm!

     

    Thanks Paul!

    Trevor

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply