Problem setting Package Variables in SSIS Package

Hi,

I am making use of the DtUtil tool to deploy my package to SQL Server.
Following is my configuration:
32-bit machine and 32-bit named instance of Yukon.

I have some package variables which need to be set in the code.

Previously I did it as follows:

Set the package variables in the code. For example:

pkgFile.Variables["User::DestinationServerName"].Value = <myvalue>

Deploy the package as follows:

applnObj.SaveToSqlServer(pkgFile, null,
destinationServer, null, null);

Here the package was successfully deployed and when i open those packages using BIDS, I am able to see that the variables are set to the values as doen in teh code.


Because of oen problem I am not using SaveToSQLServer method. So I switched to DTUtil tool.
Now I am doing it this way:

Set the package variables as before.
Deploy the package to SQL Server using DTUtil tool.

Now is the problem:
The package is successfully deployed. But the variables are not set to the value that I have specified in the code.

I also tried DTexec utility to set the package variable. Even that does n't work.
Can anyone help me out Is there any alternate method to set package variables

Thanks,
Sandhya




Answer this question

Problem setting Package Variables in SSIS Package

  • cookieCutter

    Hi,

    I have added my comment in the link. Thanks for the info.



  • Jassim Rahma

    Indeed, the text is misleading, I agree with you. I'll send notice to documentation guys. You can also send comments at the bottom of the page at msdn page.

    The package format is indeed XML, but it is common to give packages .DTSX extention to show they are SSIS packages.

    BTW, SSIS usually does not care about the file extention (except the designer project system) - so you'll be able to execute a package even if it has .XML extention.

  • William Nordgren

    Hi,

    Its resolved noiw. the problem was that I was not making use of the package object (using which i set the package ariables to the required values) in DTUtil. That was the reason why the variables were not getting modified.

    My requirement id that I need to save the package to MSDN folder.

    Now I am doing it this way:

    Set the package variables

    Use SaveToDtsServer method to save the package to File system folder in Integration Services. (Im doing this because when I use SavetoSQLServer method, I am getting a 'Communication Link Failure' error.)

    Copy the package from File System to MSDB folder in Integration Services.

    Delete the package from File System folder in Integration Services.

    Now my package is successfully deployed and the variables are also set accordingly.

    But is there a way by which I can save the modified package to the local system's physical location rather than the File System folder in Integration Services



  • Vishal_LogicaCMG

    I am not sure what you mean by setting the package variables in the code. Are you referring to the code in a script task

    To dynamically update variables, you can create configurations for the variables, deploy the configurations with the package, and then update the variable values in the configuration file when you deploy the packages. At run time, the package uses the updated variable values. For more information, see Creating Package Configurations.


  • Christian Hayter

    Hi,

    Visual Studio gives the defenition for SaveToXml mehtod as follows:

    The Name of the xml file to save the package as. Make sure to add the XML file name extension to the name.

    Why is there a reference to xml while we are actually saving a dtsx package to a physical location Is n't this misleading

    Thanks,

    Sandhya



  • Aaron Spilman

    sandyJ wrote:

    But is there a way by which I can save the modified package to the local system's physical location rather than the File System folder in Integration Services

    Of course: use Application.SaveToXml method - it takes file name and package.



  • Big5824

    sandyJ wrote:

    Now I am doing it this way:

    Set the package variables as before.
    Deploy the package to SQL Server using DTUtil tool.

    Now is the problem:
    The package is successfully deployed. But the variables are not set to the value that I have specified in the code.

    Do you save the package after modifying the variables :)

    Any modifications to the package are done to the in-memory copy of the package, you need to save this modified package to original location for your modifications to have any effect on the file.



  • Problem setting Package Variables in SSIS Package