CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2011
    Location
    Tennessee
    Posts
    19

    [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();
    Last edited by godistop1; May 22nd, 2013 at 04:26 PM.

  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    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?

  3. #3
    Join Date
    Apr 2011
    Location
    Tennessee
    Posts
    19

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured