ActiveX Script to Script Task

  • I am just a beginner in SSIS and having a problems to convert this ActiveX script task code to Script Task.I just know that ActiveX script task will be deprecated in SSIS 2008.

    Could anyone help me?

    Function Main()

    Dim strFileName, strFilePath, strDateTime, fso,strArchivePath

    strFilePath = DTSGlobalVariables("File_Directory").Value

    If Right(strFilePath, 1) <> "\" Then

    strFilePath = strFilePath & "\"

    End If

    strDateTime = Right("0" & Month(Date),2) & Right("0" & Day(dateadd("d",-1,Date) ),2) & Year(Date)

    ' First file

    strFileName=DTSGlobalVariables("First_File_Name").Value

    'Backup First file

    strArchivePath = DTSGlobalVariables("Archive_Directory").Value

    If Right(strArchivePath, 1) <> "\" Then

    strArchivePath = strFilePath & "\"

    End If

    Set fso = CreateObject("Scripting.FileSystemObject")

    fso.CopyFile strFileName, strArchivePath & "Overpack_" & strDateTime & ".txt", True

    ' Second file

    strFileName=DTSGlobalVariables("Second_File_Name").Value

    'Backup Second file

    fso.CopyFile strFileName, strArchivePath & "Product_" & strDateTime & ".txt", True

    Main = DTSTaskExecResult_Success

    End Function

    This code is actually from DTS migration to SSIS. After migration, it become ActiveX script task.i need to convert this task to script task.

    help me please....(-_-)....

    thanks

  • Hey I got with the same problem, could you solve it? I need help too

    :w00t:

  • Me three !!!! I hate SSIS !:crazy::angry:

  • not sure whether this could help or not. But it works for me.Good Luck:D

    Public Sub Main()

    Dim strFileName, strFilePath, strDateTime, strArchivePath As String

    strFilePath = "\\pg\FlexDirectory\FTP"

    If Right(strFilePath, 1) <> "\" Then

    strFilePath = strFilePath & "\"

    End If

    strDateTime = Right("0" & Month(Now.Date), 2) & Right("0" & Day(DateAdd("d", -1, Now.Date)), 2) & (Year(Now.Date))

    'First File

    strFileName = "\\pg\FlexDirectory\FTP\Bax\first.txt"

    'Backup first file

    strArchivePath = "C:\FTP\Archive\Bax"

    If Right(strArchivePath, 1) <> "\" Then

    strArchivePath = strArchivePath & "\"

    End If

    FileSystem.FileCopy(strFileName, strArchivePath & "First_" & strDateTime & ".txt")

    ' Second file

    strFileName = "\\pg\FlexDirectory\FTP\Bax\second.txt"

    'Backup Second file

    FileSystem.FileCopy(strFileName, strArchivePath & "Second_" & strDateTime & ".txt")

    Dts.TaskResult = Dts.Results.Success

    End Sub

  • Also I put down 'Main' in the Entry method and it seemed to work.

  • Yes I could solved that and other detail , I needed change the source of a text file , because the dynamic properties died, well I could solved that changing the property "Expression" of the source flat file

    But what a horibble:w00t:!!!!! the mapping of my transformation died !!!!

    OH nooooo and it is a big file with fixed width

    Fog!!!

    PD : Excuse my bad english

    Greetings from Chile

  • My preference in a case like this would be to use SSIS File tasks to copy the files. I'd encourage you to remember that a lot of functions now found in SSIS weren't available in DTS, so we had to build them with scripts or whatever. This example given in the original post looks like a classic case.

    You'll want to set up your file tasks to do the Copy File using expressions that contain the source and target file names.

    And don't worry about your English. It's much better than my Spanish 🙂

  • Alas, now I have problem the DTSTaskExecResult_Failure

    it doesnt work !!! :w00t::crazy:

    exists another way to handle the errors??? thank you for your mercy

    what hell the bill gate team dont do avaible with dts I will kill them....

  • You should use

    Dts.TaskResult = Dts.Results.Failure

  • Yeah thank you, I could solved , I had to rewrite my ActiveX Task to

    Script Task in VB.net ,as Houdini said

    "it is easy if you know how to do it " 😀

  • Hector,

    I'm curious. Why do you want to use a script to copy files rather than use the built-in file tasks that come with SSIS?

  • I am using a task tranformation but it is the path that I must to validate , so if exists some file or not , in my Dts I was doing that with an ActiveX

    so one time validated , I will pass the path with a dynamic properties to the transformation

    Well now in my ssis , I replaced the dynamic properties with a Expression user variable and the ActiveX was changed by a Script Task with VB.NET

    Thank you for their helpings

  • why don't you simply use "File System task" task in control flow and copy or move or renames

  • azhuravel (4/16/2013)


    why don't you simply use "File System task" task in control flow and copy or move or renames

    You are responding to a post which is nearly five years old.

    If you haven't even tried to resolve your issue, please don't expect the hard-working volunteers here to waste their time providing links to answers which you could easily have found yourself.

Viewing 14 posts - 1 through 13 (of 13 total)

You must be logged in to reply to this topic. Login to reply