【发布时间】:2010-09-22 18:34:20
【问题描述】:
我正在学习 SSIS,这似乎是一项简单的任务,但我被困住了。
我有一个包含这些数据的 CSV 文件 Orders.csv:
ProductId,Quantity,CustomerId
1,1,104
2,1,105
3,2,106
我还有一个存储过程 ssis_createorder 作为输入参数: @productid 整数 @数量整数 @customerid 整数
我想要做的是创建一个 SSIS 包,它将 .csv 文件作为输入,并为 .csv 文件中的每一行调用 ssis_createorder 三次(第一行包含列名)。
这是我到目前为止所做的。
我创建了一个 SSIS 包(Visual Studio 2005 和 SQL Server 2005)。
在控制流中,我有一个数据流任务。
数据流具有我的 .csv 文件的平面文件源。所有列都已映射。
我创建了一个名为 Orders 类型的 Object 变量。我还有 int32 类型的变量 CustomerId、ProductId 和 Quantity。
接下来我有一个记录集目标,它将 .csv 文件的内容分配给变量订单。我不确定如何使用这个工具。我将变量名称(在客户属性下)设置为 User::orders。我认为现在的订单包含一个由原始 .csv 文件的内容组成的 ADO 记录集。
接下来,我将在控制流标记上添加一个 ForEach 循环容器并将其链接到数据流任务。
在 ForEach 循环容器内部,我将枚举器设置为“ForEach ADO 枚举器”。我将“ADO 对象源变量”设置为 User::orders。对于枚举模式,我选择“第一个表中的行”。
在变量映射选项卡中,我有 User::ProductId index 0、User::Quantity index 1、User::CustomerId index 2。我不确定这是否正确。
接下来我在 ForEach 循环容器中有一个脚本任务。
我已将 ReadOnlyVariables 设置为 ProductId。
在 Main 方法中,这就是我正在做的事情:
Dim sProductId As String = Dts.Variables("ProductId").Value.ToString
MsgBox("sProductId")
当我运行包时,我的 ForEach 循环容器变为亮红色,并且我收到以下错误消息
Error: 0xC001F009 at MasterTest: The type of the value being assigned to variable "User::ProductId" differs from the current variable type. Variables may not change type during execution. Variable types are strict, except for variables of type Object.
Error: 0xC001C012 at Foreach Loop Container: ForEach Variable Mapping number 1 to variable "User::ProductId" cannot be applied.
Error: 0xC001F009 at MasterTest: The type of the value being assigned to variable "User::Quantity" differs from the current variable type. Variables may not change type during execution. Variable types are strict, except for variables of type Object.
Error: 0xC001C012 at Foreach Loop Container: ForEach Variable Mapping number 2 to variable "User::Quantity" cannot be applied.
Error: 0xC001F009 at MasterTest: The type of the value being assigned to variable "User::CustomerId" differs from the current variable type. Variables may not change type during execution. Variable types are strict, except for variables of type Object.
Error: 0xC001C012 at Foreach Loop Container: ForEach Variable Mapping number 3 to variable "User::CustomerId" cannot be applied.
Warning: 0x80019002 at MasterTest: SSIS Warning Code DTS_W_MAXIMUMERRORCOUNTREACHED. The Execution method succeeded, but the number of errors raised (12) reached the maximum allowed (1); resulting in failure. This occurs when the number of errors reaches the number specified in MaximumErrorCount. Change the MaximumErrorCount or fix the errors.
SSIS package "Package.dtsx" finished: Failure.
Dts.TaskResult = Dts.Results.Success
任何帮助将不胜感激
【问题讨论】:
标签: sql-server sql-server-2005 ssis