script task error.

  • Hi,

    I want to delete old files from folders as well as subfolders.I am using the following stuff.

    I am using foreach loop.In that i took a script task.I declared variables daysback, daysback in foreach scope.I am assigning these variables to readonlyvariables user::daysback,user::filefocus in script task.

    Public Sub Main()

    Dim fi As FileInfo

    'Dim ModifiedTime As DateTime

    Try

    fi = New FileInfo(Dts.Variables("User::filefocus").Value.ToString())

    if (fi.CreationTime < (Convert.ToDateTime(Dts.Variables("User::daysback").Value))

    Dts.TaskResult = Convert.ToInt32(ScriptResults.Success)

    End If

    Catch ex As Exception

    Dts.Events.FireError(1, "", "OOPS!!! " + ex.Message.ToString(), "", 0)

    End Try

    End Sub

    i am using this script but getting following error.

    " Error: Failed to lock variable "user::daysback" for read access with error 0xC0010001 "The variable cannot be found. This occurs when an attempt is made to retrieve a variable from the Variables collection on a container during execution of the package, and the variable is not there. The variable name may have changed or the variable is not being created.".

    Plzzzzzzzzz help as deadline is over.

  • Have you ensured your variables are listed in either the ReadOnlyVariables or the ReadWriteVariables in the Script Task Editor? Or are your variables in a different namespace?

  • hi paul,

    I have added variables as ReadOnlyVariables.

    Can u plz tell me how to check namespace?

  • Hi abhas

    Write the variable name in script task as User::daysback instead of user::daysback and then try

    Incase any query let me know

    Rashmi

Viewing 4 posts - 1 through 3 (of 3 total)

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