We help IT Professionals succeed at work.

vb script using variables

aneilg
aneilg asked
on
how do i change this code so i am reading the date from my select statement
Try

            Dim ht As New Collections.Hashtable(20)
            Dim c As New OleDbConnection( _
                      Dts.Connections.Item("Data Warehouse").ConnectionString)
            Dim sqlCommand As New OleDbCommand( _
                      "SELECT Extraction_Date FROM ELTO_Extraction_Date", c)

            c.Open()
            Dim sqlResult As OleDbDataReader
            sqlResult = sqlCommand.ExecuteReader()
            While sqlResult.Read()
                If Dts.VariableDispenser.Contains( _
                                            "User::" + sqlResult.GetString(0)) Then
                    ht.Add(sqlResult.GetString(0), sqlResult.GetString(1))
                    Dts.VariableDispenser.LockForWrite("User::" + sqlResult.GetString(0))
                End If
            End While
            sqlResult.Close()

            Dim vars As Variables
            Dts.VariableDispenser.GetVariables(vars)

            Dim de As Collections.DictionaryEntry
            For Each de In ht
                vars(de.Key).Value = de.Value

            Next
            vars.Unlock()


            Process_Files()

            Dts.TaskResult = Dts.Results.Success

        Catch ex As Exception

        End Try
    End Sub


    Public Sub Process_Files()

        '---------------------------------- Sets the date and output path
        sDate = Right("00" & Day(Now()), 2) & Right("0" & Month(Now()), 2) & Right("00" & Year(Now()), 2)

Open in new window

Comment
Watch Question

Project Lead
Top Expert 2011
Commented:
Try like this

sqlResult.GetString("Extraction_Date")

OR


sqlResult.Item("Extraction_Date")

Author

Commented:
do you mean sdate = sqlResult.GetString("Extraction_Date")

Author

Commented:
partly