我使用EzApi创建SSIS包。但是,我无法创建具有多个源和单个目标的包。例如,两个OLEDB源和单个OLEDB目的地。 我想知道的是如何使用c#代码添加合并转换。 请帮忙
答案 0 :(得分:2)
在 EzApi 中有一个名为EzMerge
的组件
如果需要创建自定义数据流 - 可以使用名为EzDataFlowPackage
的基类:
class MyPackage: EzDataFlowPackage
{
public EzOleDbSource src1;
public EzOleDbSource src2;
public EzMerge merge;
public EzOleDbDest dest;
public EzOleDbConnectionManager srcConnMgr1;
public EzOleDbConnectionManager srcConnMgr2;
public EzOleDbConnectionManager destConnMgr;
public EzMyPackage() : base()
{
srcConnMgr1 = new EzOleDbConnectionManager(this);
srcConnMgr2 = new EzOleDbConnectionManager(this);
src1 = new EzOleDbSource(DataFlow);
src2 = new EzOleDbSource(DataFlow);
dest mew EzOleDbDest(DataFlow);
src1.Connection = srcConnMgr1;
src2.Connection = srcConnMgr2;
dest.Connection = destConnMgr;
merge = new EzMerge(DataFlow);
src1.AttachTo(merge);
src2.AttachTo(merge);
merge.AttachTo(dest);
}
public EzMyPackage(Package p) : base(p) { }
public static implicit operator EzMyPackage(Package p) { return new EzMyPackage(p); }
}
我刚输入此代码 - 因此可能包含错误。在此之后,您的包布局已准备就绪。您只需设置组件属性即可。
答案 1 :(得分:0)
我没有使用EzApi,但是在BIDS(Visual Studio)中,您需要有两个数据源,一个数据目标和一个“合并”组件来连接它:
像这样:
修改强>
关于装箱是有道理的。请查看以下链接:
http://thinkerkk.blogspot.com/2007/08/programmatically-creating-dataflow-with.html
在评论//create the Merge Transformation
//create the Merge Transformation
IDTSComponentMetaData90 merge = dataflow.ComponentMetaDataCollection.New();
merge.ComponentClassID = "DTSTransform.MergeJoin";
CManagedComponentWrapper mergeDesigntime = merge.Instantiate();
mergeDesigntime.ProvideComponentProperties();
merge.Name = "Merge Source1 and source2";
Console.WriteLine("merge created ");
merge.InputCollection[0].ExternalMetadataColumnCollection.IsUsed = false;
merge.InputCollection[0].HasSideEffects = false;
merge.InputCollection[1].ExternalMetadataColumnCollection.IsUsed = false;
merge.InputCollection[1].HasSideEffects = false;
//create path from source1 to merge
/*More code - see article*/
//create path from source2 to merge
/*More code - see article*/
以下链接也可用于以编程方式创建SSIS包: