ろ襴渚 覲
Imports System
Imports System.Data
Imports System.Math
Imports Microsoft.SqlServer.Dts.Pipeline.Wrapper
Imports Microsoft.SqlServer.Dts.Runtime.Wrapper
Imports system.Data.Odbc
Imports System.Text


Public Class ScriptMain
    Inherits UserComponent

    Dim odbcConn As OdbcConnection  
    Dim odbcCmd As OdbcCommand      
    Dim odbcParam As OdbcParameter  
    Dim odbcReader As OdbcDataReader

    Public Overrides Sub AcquireConnections(ByVal Transaction As Object)
        Dim connectionString As String
        connectionString = Me.Connections.郁屋.ConnectionString
        odbcConn = New OdbcConnection(connectionString)
        odbcConn.Open()
    End Sub
    Public Overrides Sub PreExecute()
        Dim odbcCmd As New OdbcCommand("select country, city, name cityname, state from citybycountry;", odbcConn)
        odbcReader = odbcCmd.ExecuteReader
    End Sub

    Public Overrides Sub CreateNewOutputRows()
        '
        ' Add rows by calling AddRow method on member variable called "<Output Name>Buffer"
        ' E.g., MyOutputBuffer.AddRow() if your output was named "My Output"
        '
        Do While odbcReader.Read
            With 豢0Buffer
                .AddRow()
                .country = odbcReader.GetString(0)
                .city = odbcReader.GetString(1)
                .cityname = odbcReader.GetString(2)
                .state = odbcReader.GetString(3)
            End With
        Loop
    End Sub

    Public Overrides Sub PostExecute()
        odbcReader.Close()
    End Sub

    Public Overrides Sub ReleaseConnections()
        Me.Connections.郁屋.ReleaseConnection(odbcConn)
    End Sub

End Class