SSIS包未读取工作簿中的所有Excel工作表
我正在用vb编写的脚本组件对旧SSIS包进行故障排除。它基本上连接到excel工作簿并读取其中的一些选项卡。它可能会随机读取1、2或在最罕见的情况下读取所有选项卡,但大多数情况下只读取第一个选项卡,并在开始读取第二个选项卡时无限期挂起。调试器不能在脚本组件上工作,所以这并没有多大帮助 运行包时,我在脚本组件中的代码上放置了消息框,这样我就可以看到它正在执行它的工作,也可以看到一些工作表(大部分是第一个工作表)中的结果数据,但它没有通过下一个reader.read语句SSIS包未读取工作簿中的所有Excel工作表,excel,vb.net,ssis,etl,script-component,Excel,Vb.net,Ssis,Etl,Script Component,我正在用vb编写的脚本组件对旧SSIS包进行故障排除。它基本上连接到excel工作簿并读取其中的一些选项卡。它可能会随机读取1、2或在最罕见的情况下读取所有选项卡,但大多数情况下只读取第一个选项卡,并在开始读取第二个选项卡时无限期挂起。调试器不能在脚本组件上工作,所以这并没有多大帮助 运行包时,我在脚本组件中的代码上放置了消息框,这样我就可以看到它正在执行它的工作,也可以看到一些工作表(大部分是第一个工作表)中的结果数据,但它没有通过下一个reader.read语句 Public Overrid
Public Overrides Sub PreExecute()
intImportType = Variables.ImportType
Dim tableNameLower As String = Variables.ActiveWorkSheet.ToLower.Replace("'", "")
Try
Dim MaxReader As OleDbDataReader
Dim MaxCmd As OleDbCommand
Try
MaxCmd = New OleDbCommand(Variables.MaxCommand, Conn)
MaxReader = MaxCmd.ExecuteReader()
Catch ex As Exception
'MsgBox(ex.Message)
End Try
While (MaxReader.Read)
MaxDate = CType(MaxReader.Item(0), Date)
End While
MaxReader.Close()
MaxCmd.Dispose()
Catch ex As Exception
' MsgBox(ex.Message)
End Try
ExpenseTable = CType(ReadVariable("User::ExpenseTable"), DataTable)
Dim tableNameClean As String = tableNameLower.Replace("$", "").Trim
Dim TabNameParts As String() = tableNameClean.Split(" "c)
For Each ch As Char In TabNameParts(TabNameParts.Length - 1)
If Char.IsDigit(ch) Then TabName += ch
Next
Try
Dim cmd As New OleDbCommand(Variables.Command, Conn)
reader = cmd.ExecuteReader
Catch ex As Exception
End Try
End Sub
Public Overrides Sub CreateNewOutputRows()
If IsNothing(reader) Then Return
Select Case intImportType
Case ImportType.A
Do While reader.Read
'reads these and other columns in file
part = reader("Part").ToString.Trim
Loop
Case ImportType.B
Do While reader.Read
'reads these and other columns in file
part = reader("Part").ToString.Trim
Loop
Dim Conn As OleDbConnection = New OleDbConnection(Connections.TestConnection.ConnectionString)
Dim cmd As OleDbCommand
Try
Conn.Open()
Dim sqlInsert As String = "UPDATE Table a SET valuea =" & valueA
cmd = New OleDbCommand(sqlInsert, Conn)
cmd.ExecuteNonQuery()
Catch ex As Exception
MsgBox(ex.Message)
Finally
Conn.Close()
End Try
Case ImportType.C
Do While reader.Read
'reads these and other columns in file
part = reader("Part").ToString.Trim
Loop
Case Else
Dim dt As DataTable = New DataTable
dt.Columns.Add("D", GetType(D))
dt.Columns.Add("E", GetType(E))
'Dim partDictionary As New Generic.Dictionary(Of String, Integer)
Do While reader.Read
Dim iDate As Date = DateTime.MinValue
Dim month As Date = DateTime.MinValue
Try
iDate = Convert.ToDateTime(reader.GetValue(reader.GetOrdinal("IDate")))
Catch ex As Exception
End Try
Try
Dim tmpMonthInvoiced As String = CStr(reader.GetValue(reader.GetOrdinal("Month")))
monthInvoiced = New Date(CInt(tmpMonthInvoiced.Substring(0, 4)), CInt(tmpMonthInvoiced.Substring(4)), 1)
Catch ex As Exception
monthInvoiced = DateTime.MinValue
End Try
Dim TrxDate As Date = month
If month = New Date Then TrxDate = iDate
If Month(month) = Month(iDate) And Year(month) = Year(iDate)
Then month = iDate
If Not TrxDate = DateTime.MinValue And (Month(TrxDate) = Month(MaxDate) And
Year(TrxDate) = Year(MaxDate)) Then
Dim row As DataRow = dt.NewRow
With row
.Item("Part") = reader("Part").ToString.Trim
End With
dt.Rows.Add(row)
End If
Loop
For Each element As DataRow In expenseRows
Dim tmpPartNum As String = CStr(element.Item("PartNumber"))
Next
For Each row As DataRow In dt.Rows
With ResultBuffer
.AddRow()
End With
Next
End Select
End Sub
当代码到达reader.read并为工作簿中的第一个工作表生成输出后,代码实际上只是挂起