2
我有一個SSIS包,現在失敗,出現「索引超出數組範圍」的錯誤。它發生在腳本組件任務中,但我在日誌中看不到有關它失敗的行的更多信息。這是我的腳本組件的文本,任何人都可以看到這個錯誤?我沒有改變任何東西,它突然開始失敗。在SSIS腳本組件中接收「索引超出數組範圍」錯誤
Imports System
Imports System.Data
Imports System.Math
Imports Microsoft.SqlServer.Dts.Pipeline.Wrapper
Imports Microsoft.SqlServer.Dts.Runtime.Wrapper
<Microsoft.SqlServer.Dts.Pipeline.SSISScriptComponentEntryPointAttribute> _
<CLSCompliant(False)> _
Public Class ScriptMain
Inherits UserComponent
' Wrapper for web service
'Private CurrencyInfo As RetrieveExchangeRatesOutputMessageContract
' wrapper for Response from web service
Public Overrides Sub Input0_ProcessInputRow(ByVal Row As Input0Buffer)
Try
Dim ws As New CurrencyExchangeWS.CurrencyExchangeWS
Dim inContract As New CurrencyExchangeWS.ExchangeRateInputDataContract
Dim msg As New CurrencyExchangeWS.RetrieveExchangeRatesInputMessageContract
Dim inContracts(1) As CurrencyExchangeWS.ExchangeRateInputDataContract
'Dim dt As Date = Now
'dt = dt.AddDays(-1)
inContract.RequestAsOfDate = Now
'inContract.RequestAsOfDate = "2011-07-18"
' IMPORTANT: You need to specify SourceCurrencyIdSpecified and TargetCurrencyIdSpecified or the service will assume these values are null.
inContract.SourceCurrencyIdSpecified = True
inContract.SourceCurrencyId = Row.CurrencyTypeId
inContract.TargetCurrencyIdSpecified = True
inContract.TargetCurrencyId = 47
inContracts(0) = inContract
msg.ExchangeRateInputCollection = inContracts
ws.Credentials = System.Net.CredentialCache.DefaultCredentials
Dim outMsg As CurrencyExchangeWS.RetrieveExchangeRatesOutputMessageContract = ws.RetrieveExchangeRates(msg)
'Dim rate =outMsg.ExchangeRateInfoCollection(0).Rate
Dim rate As Decimal = outMsg.ExchangeRateInfoCollection(0).Rate
'Dim edate = outMsg.ExchangeRateInfoCollection(0).RequestAsOfDate
Dim edate = outMsg.ExchangeRateInfoCollection(0).RateAsOfDate
'Dim edate As DateTime
'edate = outMsg.ExchangeRateInfoCollection(0).RateAsOfDate
Row.date = edate
Row.rate = Convert.ToDecimal(1.0/rate)
'Dim currency = outMsg.ExchangeRateInfoCollection(0).TargetCurrencyId
Catch ex As Exception
ComponentMetaData.FireError(1, ComponentMetaData.Name, ex.Message, String.Empty, 0, True)
End Try
End Sub
Public Overrides Sub PreExecute()
MyBase.PreExecute()
'
' Add your code here for preprocessing or remove if not needed
''
End Sub
Public Overrides Sub PostExecute()
MyBase.PostExecute()
'
' Add your code here for postprocessing or remove if not needed
' You can set read/write variables here, for example:
' Me.Variables.MyIntVar = 100
''
End Sub
'Public Overrides Sub Input0_ProcessInputRow(ByVal Row As Input0Buffer)
'
' Add your code here
'
'End Sub
End Class
而最好的方法,給出了無法在SSIS 2005-2008R2中調試腳本組件是將您的Try/Catch塊複製到新的VB控制檯應用程序中,然後從那裏進行調試。看來你需要的唯一的輸入是'Row.CurrencyTypeId'這樣的硬編碼,只有幾個例子。 – billinkc