【问题标题】:Can we fetch the file stored in the filestream through ssis script task?我们可以通过 ssis 脚本任务获取存储在文件流中的文件吗?
【发布时间】:2011-12-08 11:28:33
【问题描述】:

我正在尝试使用 ssis 脚本任务从文件流中获取文件并将文件放在目标文件夹中,这是他们实现此功能的任何标准方法。

【问题讨论】:

  • 为什么把 azure 和 sql-azure 作为标签?
  • 是的,我的文件流将填充从 azure 容器获得的数据,这就是我将其标记为 azure 的原因,抱歉在 sql-azure 下进行标记

标签: asp.net sql-server-2008 ssis azure


【解决方案1】:
using System;

using System.Data;
using Microsoft.SqlServer.Dts.Pipeline.Wrapper;
using Microsoft.SqlServer.Dts.Runtime.Wrapper;
using System.Xml;

[Microsoft.SqlServer.Dts.Pipeline.SSISScriptComponentEntryPointAttribute]

public class ScriptMain : UserComponent
{
    //Initialize XML Document to read the XML file
    private XmlDocument xDoc = new XmlDocument();

    public override void PreExecute()
    {
        base.PreExecute();

        //Provide the path to read the XML file and load the xml document
        xDoc.Load(@"C:\XML Sample\Input.xml");

    }

    public override void CreateNewOutputRows()
    {
        //Iterate through each node which has the value "Employee" 
        // "//Employee" is the xpath to fetch all occurences of Employee node in the XML
        foreach (XmlNode xNode in xDoc.SelectNodes("//Employee"))
        {
            //Add new row to the output buffer for each employee node in the XML file
            this.EmployeeBuffer.AddRow();

            //Assign values to the columns.

            //Read the 1st attribute of the node Employee
            this.EmployeeBuffer.EmpID= xNode.Attributes[0].Value;

            //Read the 1st Child node of the node Employee
            this.EmployeeBuffer.Name= xNode.ChildNodes[0].InnerText;

            //Read the 2nd Child node of the node Employee
            this.EmployeeBuffer.Age= xNode.ChildNodes[1].InnerText;
        }
    }

    public override void PostExecute()
    {
        base.PostExecute();
    }
}

【讨论】:

    猜你喜欢
    • 2020-11-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-07-08
    • 2023-03-10
    • 1970-01-01
    • 2014-04-13
    • 2018-11-02
    相关资源
    最近更新 更多