Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
arkiboys
Master Smack Fu Yak Hacker
1433 Posts |
Posted - 2011-10-07 : 07:33:37
|
In ssis 2008 script task, I would like tho get the name of the file as follows but the mesasge box shown an empty string. Do you see why please? thankspublic void Main() { Dts.Variables["FileName"].Value = System.IO.Path.GetFileName(Dts.Variables["FileName"].Value.ToString()); MessageBox.Show(Dts.Variables["FileName"].Value.ToString()); Dts.TaskResult = (int)ScriptResults.Success; } |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-10-07 : 07:44:45
|
yyou're trying to assign filename stored in fileName variable to itself? sorry posted code doesnt make much sense------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
arkiboys
Master Smack Fu Yak Hacker
1433 Posts |
Posted - 2011-10-07 : 07:50:58
|
I see what you mean...In that case what should this line be to get the filename?I think I have to to pass the filelocatioin path but how and should it be hard coded?ThanksDts.Variables["FileName"].Value = System.IO.Path.GetFileName( |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-10-07 : 07:52:39
|
you've to pass file location path. why not hold it in another variable and pass it as input to script?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
arkiboys
Master Smack Fu Yak Hacker
1433 Posts |
Posted - 2011-10-07 : 09:36:11
|
In scrip task editor, The readonlyVariables is set to User::SourceDirectoryPath and ReadWriteVariables set to User::FileNameError is:The element can not be fouond in a collection public void Main() { Dts.Variables["FileName"].Value = System.IO.Path.GetFileName(Dts.Variables["SourceDirectoryPath"].Value.ToString()); MessageBox.Show(Dts.Variables["FileName"].Value.ToString()); Dts.TaskResult = (int)ScriptResults.Success; }Any thouoghts please?Thanks |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-10-07 : 12:23:31
|
did you add sourcefilepath variable in package at all?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
arkiboys
Master Smack Fu Yak Hacker
1433 Posts |
Posted - 2011-10-07 : 12:58:29
|
got it, thanks again. |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-10-07 : 13:07:55
|
wc------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
|
|
|