I have tried to close the recordset but the close method does not appear to be valid in the main code,( I tried Me.Variables.MyRecordSet2.close). Do I need to override one of the Class methods The code I used is modified from one of Jamie Thomsons blogs and is as below:
Imports System
Imports System.Data
Imports System.Math
Imports Microsoft.SqlServer.Dts.Pipeline.Wrapper
Imports Microsoft.SqlServer.Dts.Runtime.Wrapper
Public Class ScriptMain
Inherits UserComponent
Public Overrides Sub CreateNewOutputRows()
'
Dim olead As New Data.OleDb.OleDbDataAdapter 'Define an ADO.Net data adapter
Dim dt As New Data.DataTable 'Define an ADO.Net DataTable
Dim row As System.Data.DataRow 'Define an ADO.Net DataRow
Dim lastSI, SI As Int32
Dim strU(50) As String
Dim strU2(50) As String
Dim dblFactor(50) As Double
Dim x, y, j, k As Int32
Dim isFirst As Boolean
Dim strLComb, strComb As String
olead.Fill(dt, Me.Variables.MyRecordSet2) 'Populate our DataTable from the adapter
lastSI = 0
strLComb = " "
SI = 0
x = 0
isFirst = True
For Each row In dt.Rows 'Iterate over the rows in the table
strComb = row("SI").ToString & row("U").ToString
If strComb <> strLComb Then
If isFirst Then
isFirst = False
Else
For y = 1 To (x - 1)
For k = 2 To x
With OutputBuffer
.AddRow()
.Calculated = True
.Factor = dblFactor(k) / dblFactor(y)
.SI = SI
.U = strU2(y)
.U2 = strU2(k)
End With
Next
Next
End If
SI = CType(row("SI"), Integer)
strLComb = row("SI").ToString & row("U").ToString
x = 1
strU(x) = row("U").ToString
strU2(x) = row("U2").ToString
dblFactor(x) = CType(row("Factor"), Double)
Else
x = x + 1
strU(x) = row("U").ToString
strU2(x) = row("U2").ToString
dblFactor(x) = CType(row("Factor"), Double)
End If
Next
For y = 1 To (x - 1)
For k = 2 To x
With OutputBuffer
.AddRow()
.Calculated = True
.Factor = dblFactor(k) / dblFactor(y)
.SI = SI
.U = strU2(y)
.U2 = strU2(k)
End With
Next
Next
dt.Dispose()
End Sub
End Class