code in ScriptTask
-
Thursday, January 31, 2013 5:19 AM
In my SSIS package, I want to select an excel dynamically and store the file absolute path in a variable. I choose script task. Following is source code of entry method. The question is, script task will keep running and no dialog displays. Does anyone know why this happens? highly appreciated.
public void Main() { // TODO: Add your code here OpenFileDialog dialog = new OpenFileDialog(); //dialog.DefaultExt = "xlsx"; dialog.Title = "Source Excel"; dialog.CheckFileExists = true; dialog.AddExtension = true; dialog.DefaultExt = "xlsx"; dialog.ShowDialog(); string fileName = dialog.FileName; Dts.Variables["User::SourceExcel"].Value = fileName; Dts.TaskResult = (int)ScriptResults.Success; }
All Replies
-
Thursday, January 31, 2013 6:04 AM
Catherine, this is not good. Conceptually, an ETL is a batch process and in the project life time it will be executed in an un-attended mode? Why do you have a user interaction (aka a dialog box) here?
What is it that you are trying to achieve?
Please vote as helpful or mark as answer, if it helps
Cheers, Raunak | t: @raunakjhawar | My Blog -
Thursday, January 31, 2013 10:56 AM
I agree with Raunak that you should not use a dialog in an SSIS package. It is possible that the dialog will not show when you run the package outside of BIDS.
If this happens while running the package in BIDS, put a breakpoint in the script at the first line of the script and step through it. http://beyondrelational.com/modules/12/tutorials/24/tutorials/9086/getting-started-with-ssis-part-9-debugging-ssis-packages.aspx.
Russel Loski, MCT, MCSA SQL Server 2012, 2008, MCITP Business Intelligence Developer and Database Developer 2008 Twitter: @sqlmovers; blog: www.sqlmovers.com
-
Thursday, January 31, 2013 12:47 PMModerator
I agree with the gents above... big no no... But I have tested it and the ShowDialog method just won't display something visual in a Script Task.
Best options is to use configurations... or if you really want a dialog then make a small windows app that does the dialog and then calls a ssis package with that value from the dialog as variable/parameter.
Please mark the post as answered if it answers your question | My SSIS Blog: http://microsoft-ssis.blogspot.com | Twitter
- Proposed As Answer by Russ Loski Thursday, January 31, 2013 12:53 PM
- Edited by SSISJoostMicrosoft Community Contributor, Moderator Thursday, January 31, 2013 1:33 PM
- Marked As Answer by Catherine0824 Monday, February 04, 2013 2:29 AM

