[RESOLVED] Calling SSIS 2005 Package from C# - Error "Specified cast is not valid"
I hope this is the right place to ask this question. I have web browser application that calling a SSIS 2005 package and I am using VS 2010 and 4.0 .net. When I run the application and it gets to executing the package I get this error: "Specified cast is not valid". I need to pass several parameters to the package, following is my code. I have also tried loading the date variable with the conversion.
Application app = new Application();
Package package = null;
DTSExecResult results;
package = app.LoadPackage(@"\\Bnawpus01\\Public\\bhill\\Projects - SSIS\\OIA CPT Analysis Detail - Payment Split\\CPT Analysis Detail - Payment Split - Prompt\\CPT Analysis Detail.dtsx", null);
package.Variables["User::varDatabase"].Value = Session["Practice"].ToString();
package.Variables["User::varGroupBy"].Value = Session["Practice"].ToString();
DateTime dteStart = DateTime.Parse(Session["FromDate"].ToString());
package.Variables["User::varStartDte"].Value = dteStart.ToShortDateString();
DateTime dteEnd = DateTime.Parse(Session["ToDate"].ToString());
package.Variables["User::varEndDte"].Value = dteEnd.ToShortDateString();
results = package.Execute();
Re: Calling SSIS 2005 Package from C# - Error "Specified cast is not valid"
Have you stepped through the code in the debugger to see which parameter the conversion is failing on?
Re: Calling SSIS 2005 Package from C# - Error "Specified cast is not valid"
I found the answer, I changed the date parameter to string and package executed correctly.