首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >从代码设置SSIS路径上的PathAnnotation

从代码设置SSIS路径上的PathAnnotation
EN

Stack Overflow用户
提问于 2010-09-27 20:34:03
回答 1查看 1K关注 0票数 0

我最近一直在尝试从.NET代码创建SSIS包,而不是在Visual Studio中使用拖放。作为包文档的一部分,我希望能够注释数据流路径。

下面的代码-复制自MSDN -在两个SSIS数据流组件之间建立了一条路径。通过添加

代码语言:javascript
复制
    path.Name = "My name";
    new Application().SaveToSqlServer(package, null, "localhost", "myUser", "myPassword");

我可以将路径名称设置为任何我喜欢的名称,然后将包保存在本地SQL Server中。但是,当我在Visual Studio2008中打开该包时,只能在path属性下看到路径的名称。

在Visual Studio中,还有另一个路径属性PathAnnotation,它的值为AsNeeded,附加的可能性是SourceName、PathName、Never。将值更改为PathName会得到我想要的结果:路径名显示在Visual Studio中的数据流选项卡中的路径旁边。

我的问题是:是否可以从代码中设置PathAnnotation属性的值?

代码语言:javascript
复制
using System;
using Microsoft.SqlServer.Dts.Runtime;
using Microsoft.SqlServer.Dts.Pipeline;
using Microsoft.SqlServer.Dts.Pipeline.Wrapper;

namespace Microsoft.SqlServer.Dts.Samples
{
  class Program
  {
    static void Main(string[] args)
    {
      Package package = new Package();
      Executable e = package.Executables.Add("STOCK:PipelineTask");
      TaskHost thMainPipe = e as TaskHost;
      MainPipe dataFlowTask = thMainPipe.InnerObject as MainPipe;

      // Create the source component.  
      IDTSComponentMetaData100 source =
        dataFlowTask.ComponentMetaDataCollection.New();
      source.ComponentClassID = "DTSAdapter.OleDbSource";
      CManagedComponentWrapper srcDesignTime = source.Instantiate();
      srcDesignTime.ProvideComponentProperties();

      // Create the destination component.
      IDTSComponentMetaData100 destination =
        dataFlowTask.ComponentMetaDataCollection.New();
      destination.ComponentClassID = "DTSAdapter.OleDbDestination";
      CManagedComponentWrapper destDesignTime = destination.Instantiate();
      destDesignTime.ProvideComponentProperties();

      // Create the path.
      IDTSPath100 path = dataFlowTask.PathCollection.New();
      path.AttachPathAndPropagateNotifications(source.OutputCollection[0],
        destination.InputCollection[0]);
    }
  }
EN

回答 1

Stack Overflow用户

发布于 2010-10-06 21:14:29

我成功地在不同的论坛上得到了答案。请参阅

http://social.msdn.microsoft.com/Forums/en-US/sqlintegrationservices/thread/23e6a43f-911f-44da-8e69-cd9e53d7e5ed

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/3803774

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档