all groups > sql server dts > december 2006 >
You're in the

sql server dts

group:

SSIS Error: Failed to lock variable xx for read access - Script Task under Foreach Container


SSIS Error: Failed to lock variable xx for read access - Script Task under Foreach Container jobs
12/15/2006 11:46:20 AM
sql server dts:
Perhaps somebody in this news group knows.

In SSIS


I have a foreach container thats got an filename enumeration collection

of files in a directory stored in a variable I call FileName.


Inside the foreach container, I have script task (vb.net) that I want
to pass that FileName variable to. So I presume I pass it as a
ReadonlyVariable.


In the script task I'm setting the ReadOnlyVariables to
@[User::FileName]


:
Imports System.IO
Imports System
Imports System.Data
Imports System.Math
Imports Microsoft.SqlServer.Dts.Runtime


Public Class ScriptMain


Public Sub Main()
Dim fname As String = CType(Dts.Variables("FileName").Value,
String)
File.Move(fname, fname + ".processed")
Dts.TaskResult = Dts.Results.Success
End Sub


End Class


But now getting this error:


Error: Failed to lock variable "\\xxxx\Data\f1.csv" 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.".


As you can see the variable does appear to be resolving .. but the step
is still failing
RE: SSIS Error: Failed to lock variable xx for read access - Script T Todd C
12/17/2006 6:15:00 PM
Try the CStr(Dts.Variables("fName").Value) conversion.

I'm not a Script expert by any means but the CStr( ) has worked good for me
in the past.

HTH
--
Todd Chittenden


[quoted text, click to view]
AddThis Social Bookmark Button