error when running script task

  • I am getting following message when running the script task:

    Error: Failed to lock variable "user::varTest" for read/write 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.".

    I cant figure out whats going on. Here is the design script:

    ' 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.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()

    '

    ' Add your code here

    '

    Dts.Variables("varTest").Value = 2

    MsgBox(Dts.Variables("varTest").Value)

    Dts.TaskResult = Dts.Results.Success

    End Sub

    End Class

    There is nothing fancy going on here. I have defined the variable varTest in SSIS which has the package scopr and its on type int32.

    Any clue what am I doing wrong here?

  • Did you forget to add the variable to the ReadWrite Variables property on the component?

Viewing 2 posts - 1 through 1 (of 1 total)

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