【发布时间】:2019-07-24 17:41:49
【问题描述】:
我在 VS 2012 中使用 SSIS,我发现的许多答案似乎都适用于旧版本或新版本。
我已经声明了一个名为 User::Weather_XML 的 ReadWriteVariables (我希望这会显示 - 我的公司政策不允许访问 imgur,所以它看起来有效,但我不知道。)
我看了很多答案: Reading object variable values in SSIS script component source - 这是指 Dts.Variables,它显然在 2012 年不再可用?
所以我的代码有这个,但它不会编译,因为 Dts.Variables 在当前上下文中不存在:
DataTable dt = new DataTable();
OleDbDataAdapter oleda = new OleDbDataAdapter();
oleda.Fill(dt, Dts.Variables("Weather_XML").Value);
如何将数据集放入脚本组件中以便我可以使用它?
我有一个带有 URL 字符串的数据集 - 我想遍历列表并使用每个 URL,获取相应的 XML,然后将其保存回我的对象。或将其写入数据库或其他东西。似乎这只是语法,但我无法弄清楚。
This 使用 IDTSVariables100,但随后将其引用到字符串,我有一个完整的对象,其中包含字符串。如果我添加代码
IDTSVariables100 varCollection = null;
this.VariableDispenser.LockForRead("User::Weather_XML");
它确实编译了,所以它是进步的。
我的 C# 很弱。明显地。 2012 年需要什么语法才能将 Object 变量转换为我可以在脚本组件中使用的东西?随着,也许一些关于访问对象的特定部分的指导。假设 URL 是对象中的第一个字符串字段,而我目前有 4 行。
另外,我包含以下命名空间,可能比我需要的要多:
using System;
using System.Data;
using Microsoft.SqlServer.Dts.Pipeline.Wrapper;
using Microsoft.SqlServer.Dts.Runtime.Wrapper;
using System.Net;
using Microsoft.SqlServer.Dts.Runtime;
using System.Windows.Forms;
using System.IO;
using System.Web.Script.Serialization;
using System.Xml;
using System.Xml.Serialization;
using System.Collections.Generic;
using System.Data.OleDb;
【问题讨论】: