vb.net - SSIS Scripting Task Can't Find Variable -


i have ssis package scripting task set file's name , location. tried update add incrementing number end of file name. when run it, error message:

error: 0xc0014054 @ script task: failed lock variable "system.reflection.targetinvocationexception: exception has been thrown target of invocation. ---> microsoft.sqlserver.dts.runtime.dtsruntimeexception: element cannot found in collection. error happens when try retrieve element collection on container during execution of package , element not there.  ---> system.runtime.interopservices.comexception (0xc0010009): element cannot found in collection. error happens when try retrieve element collection on container during execution of package , element not there. 

there's lot more after that, gist.

the thing is, finds variables earlier in same code, , since doesn't variable can't find, don't know problem is. able track down line it's failing on though here's code:

    public sub main()     dim sfile string     dim integer     dim bexists boolean      = 1     bexists = true      dts.variables("user::ustarttime").value = dts.variables("system::starttime").value     dts.variables("user::filename").value = dts.variables("user::protocol").value.tostring _                                             & "_" & cstr(format(dts.variables("user::ustarttime").value, "yyyymmdd")) _                                             & "_" & cstr(i)      dts.variables("user::filelocation").value = "\\acmshares2\clntrial\datamgt\" _                                                 & dts.variables("user::studynumber").value.tostring _                                                 & "\" + dts.variables("user::filelocation").value.tostring _                                                 & dts.variables("user::filename").value.tostring _                                                 & "." & dts.variables("user::filetype").value.tostring      'add incrementing number end of file name per dma     until bexists = false         'scripting task fails on next line         sfile = dts.variables("user::filelocation").value          if file.exists(sfile)             = + 1             dts.variables("user::filename").value = dts.variables("user::protocol").value.tostring _                                             & "_" & cstr(format(dts.variables("user::ustarttime").value, "yyyymmdd")) _                                             & "_" & cstr(i)             dts.variables("user::filelocation").value = "\\acmshares2\clntrial\datamgt\" _                                                 & dts.variables("user::studynumber").value.tostring _                                                 & "\" + dts.variables("user::filelocation").value.tostring _                                                 & dts.variables("user::filename").value.tostring _                                                 & "." & dts.variables("user::filetype").value.tostring         else             bexists = false         end if         msgbox("loop iterated")     loop      dts.taskresult = scriptresults.success end sub 

so fails when reaches line sfile = dts.variables("user::filelocation").value

any ideas?

while vb case insensitive, ssis variables are case sensitive. have used lowercase l in filelocation

sfile = dts.variables("user::filelocation").value 

Comments

Popular posts from this blog

sql server - Cannot query correctly (MSSQL - PHP - JSON) -

php - trouble displaying mysqli database results in correct order -

C++ Linked List -