Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8832019
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T08:26:15+00:00 2026-06-14T08:26:15+00:00

I am using a SSIS package with an Execute SQL Task connected to Script

  • 0

I am using a SSIS package with an Execute SQL Task connected to Script Task. The values from Execute SQL Task are stored in a variable and in the Script Task I use the following code to give XML file.

Public Sub Main()
    If My.Computer.FileSystem.FileExists("C:\SAMPLE.xml") Then
        Dts.TaskResult = ScriptResults.Failure
    Else
        My.Computer.FileSystem.WriteAllText("C:\SAMPLE.xml", Dts.Variables(0).Value.ToString, False)
        Dts.TaskResult = ScriptResults.Success
        ''
    End If
End Sub    

I don’t want to hardcode the path to XML. So I created two new variables FileName and FilePath with package as scope. How do I edit my VB.Net code to actually use these two variables.I tried this but did not work:

    Sub Main()
    If My.Computer.FileSystem.FileExists(Dts.Variables("FileDest").Value.ToString())        Else
        My.Computer.FileSystem.WriteAllText(Dts.Variables("FileDest").Value.ToString(), Dts.Variables(0).Value.ToString, False)Dts.TaskResult = ScriptResults.Success
   ''
    End If
End Sub

Ideally I want to use two variables one for name and one for path but when I tried with a single variable which combines both, it didn’t work.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T08:26:16+00:00Added an answer on June 14, 2026 at 8:26 am

    I suspect that part of your problem is using a numeric index into the Variables collection. Once you added the FileDest variable, there’s no guarantee that whatever variable was being used to store the Execute SQL Task results is still the zeroeth one in the collection.

    Assuming the variable with the Execute SQL Task results is named XmlQueryResults, the following should do the trick:

    Public Sub Main()
        Dim filePath As String = Dts.Variables("FileDest").Value
        Dim xmlToWrite As String = Dts.Variables("XmlQueryResults").Value
        If My.Computer.FileSystem.FileExists(filePath) Then
            Dts.TaskResult = ScriptResults.Failure
        Else
            My.Computer.FileSystem.WriteAllText(filePath, xmlToWrite, False)
            Dts.TaskResult = ScriptResults.Success
        End If
    End Sub
    

    (Don’t forget to add the FileDest variable to the ReadOnlyVariables in the Script Task Editor script tab.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm attempting to execute an SSIS package on SQL 2005 using the following: dtexec
I have an SSIS package that queries data from a view using an SQL
Am trying to execute ssis package using dtexec utility from c# app(Creating New Process,
How is it possible to execute a SSIS 2008 Package by using SQL in
I'm trying to execute a command using the following code snippet: foreach($package in (Get-Childitem
I'm running an SSIS package from an external scheduler (Control-M), using dtexec. I'd like
I'm using SSIS to import data from Excel sheets into SQL Server 2005, the
Is it possible to execute a SSIS package in C# Code ? We can
I need to execute an SSIS package from an .net application that's on a
I am using an SSIS package to get a text file from a secure

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.