Why cannot pre-complile script to binary code?

  • Hi, I have a script task in SSIS which dynamically find the file name. When I execute the task I got this error:

    Error at Script Task: The task is configured to pre-compile the script, but binary code is not found. Please visit the IDE in Script Task Editor by clicking Design Script button to cause binary code to be generated.

    How can I solve this problem? How can I compile the script? When I click on the start button from the Microsoft Visual Studio for Applications window (after click the Design Script button) nothing happened. How can I know my script is ok or not?

    Thanks a lot for your help!

    I have created package level variables ImportFolder and TotFileName and make ImportFolder ReadOnlyVariables and TotFileName ReadWriteVariables. Then I use expression to set the property for flat file connection manager to use the TotFileName variable. 

    -----code------

    ' Microsoft SQL Server Integration Services Script Task

    ' Write scripts using Microsoft Visual Basic

    ' The ScriptMain class is the entry point of the Script Task.

    Imports System

    Imports System.IO

    Imports System.Data

    Imports System.Math

    Imports Microsoft.SqlServer.Dts.Runtime

    Public Class ScriptMain

          ' The execution engine calls this method when the task executes.

          ' To access the object model, use the Dts object. Connections, variables, events,

          ' and logging features are available as static members of the Dts class.

          ' Before returning from this method, set the value of Dts.TaskResult to indicate success or failure.

          '

          ' To open Code and Text Editor Help, press F1.

          ' To open Object Browser, press Ctrl+Alt+J.

        Public Sub Main()

            Dim TotFileName As String

            Dim TrueFileName As String

            Dim sYear As String

            Dim sMonth As String

            Dim sDate As String

            sYear = CStr(Year(Now()))

            sMonth = CStr(Month(Now()) - 1)

            If (Month(Now()) < 11 And Month(Now()) > 1) Then

                sMonth = "0" & sMonth

            End If

            If (Month(Now()) = 1) Then

                sMonth = "12" And sYear = CStr(Year(Now()) - 1)

            End If

            sDate = sYear & sMonth

            TrueFileName = sDate & "daily.txt"

            TotFileName = CStr(Dts.Variables.Item("ImportFolder").Value) & TrueFileName

            Dts.Variables.Item("TotFileName").Value = TotFileName

            Dts.TaskResult = Dts.Results.Success

        End Sub

    End Class

  • Ok, I got the error when I was doing this on the server; I then copied the package to my local PC and then executed the Script task it executed with success (that means the syntax is correct right?). But the only problem is that when I checked the result of the variable TotFileName from the Expression builder window for the flat file connection manager it was not populated with a file name like \\MyServer\MyDrive\MyFolder\200706daily.txt. So something is still missing from the script above. Can someone help with this? Thanks a lot!!

  • On your server, set the option to precompile to false, then save the package. Go back in & set it to True once again & SSIS will receompile & create the new binaries.

    Regarding the variable not updating, make sure you pass it as a read/write variable to the script tasks.

    HTH,

    Catherine


    Kindest Regards,

    Catherine Eibner
    cybner.com.au

  • Catherine,

    Thanks very much for the reply! Yes it worked after I set the option to False and saved it and then went back in and set it to True.

    As for the variable not being populated with the filename, yes I have set the TotFileName as a ReadWrite Variable to the script task. I guess some piece might be missing from my code. Do you see anything wrong with my code? Thanks again!

     

  • Thanks Catherine,

    It worked for me as well.

    Hary

    Thanks a lot,
    Hary

  • Thanks.

    It worked for me too.

    Regards,

    Atheeq

Viewing 6 posts - 1 through 5 (of 5 total)

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