Another DTSX vb.net Question for the brave hearted

  • so far with the help of you guys , i've managed to create and deploy a vb.net application that will exacute a DTSX ... now for the tricky part. After spending hours looking through various forums and online books im still no closer to finsing out how i can parm a variable into the DTSX

    1. i want to parm in a file name as a variable. In the DTSX there is a variable called filename ... hows can i assign that a value from the vb code below ?

    Dim pkgLocation As String = ""

    Dim App As New Application

    Dim pkg As New Package

    Dim ExecEvent As IDTSEvents90

    Dim result As DTSExecResult

    pkgLocation = "\\Sql1\2007_DTS\FTPSLAVE.dtsx"

    Try

    pkg = App.LoadPackage(pkgLocation, False, ExecEvent)

    result = pkg.Execute

    MsgBox("DTS Executed - result - " & result.ToString)

    Catch ex As Exception

    MsgBox(" Execution error " & ex.Message)

    End Try

  • Stole this from some code I have previously used:

    dim pkg as new package

     

    pkg.GlobalVariables.Remove(

    "filename")

    pkg.GlobalVariables.AddGlobalVariable(

    "filename", <value&gt

    pkg.Execute()

     

    You apparently need to dynamically drop and re-add the globalvariable, just so you can assign the value as you're adding it in.  Took me a while to find this - not sure if there's any other way.

    ----------------------------------------------------------------------------------
    Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?

  • i have tried adding that code but am comming up with the following error;

    A first chance exception of type 'System.MissingMemberException' occurred in Microsoft.VisualBasic.dll

    Public member 'GlobalVariables' on type 'IDTSPackage90' not found.

  • sorry - just notice you're dealing with SSIS in this case, and the code I gave you is for "classic DTS".  SSIS seems to have slightly different syntax (such as - you don't need to recreate the variable to assign it a value (it needs to already exist).

    Example:

    package.loadpackage(...)

    package.Variables["myVar"].Value = packageVariable

    package.execute()

    ----------------------------------------------------------------------------------
    Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply