dbTalk Databases Forums  

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

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss SSIS Error: Failed to lock variable xx for read access - Script Task under Foreach Container in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
jobs
 
Posts: n/a

Default SSIS Error: Failed to lock variable xx for read access - Script Task under Foreach Container - 12-15-2006 , 01:46 PM






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


Reply With Quote
  #2  
Old   
Todd C
 
Posts: n/a

Default RE: SSIS Error: Failed to lock variable xx for read access - Script T - 12-17-2006 , 08:15 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


"jobs" wrote:

Quote:
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



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.