tags:

views:

344

answers:

1

Hi, could anybody give me any clue why this script not doing the job to write the file? in fact when i'm trying to run it on SSIS 2005, the task showed up green and success

I'm confused

Imports System
Imports System.Data
Imports System.Math
Imports Microsoft.SqlServer.Dts.Runtime
Imports System.IO

Public Class ScriptMain
Public Sub Main()

System.IO.File.AppendAllText("e:\test.txt","<![CDATA[ <b>Sales</b>]]>")

Dts.TaskResult = Dts.Results.Success
End Sub

End Class

Thank you in advance

A: 

Looks like there is a problem passing in the XML. Try the following and see if that works, if so, then the XML fragment you are adding is the issue.

Public Sub Main()
    Dim strFile As String
    Dim strText As String

    strFile = "e:\test.txt"
    strText = "test"

    Try
        File.AppendAllText(strFile, strText)
    Catch e As Exception
        Dts.TaskResult = Dts.Results.Failure
    End Try
    Dts.TaskResult = Dts.Results.Success


End Sub
revelator
Thanks for your reply Revelator,for simple string character like what you told me to do, it works fine, the file is written with "test"but do you have any other solution to write the file with exactly this character "<![CDATA[ <b>Sales</b>]]>"using Script Task?or is it a SSIS 2005 bug?? so it can't write such character?Thank you in advance
pacific
I'm not at my machine with SSIS installed at the moment, but I had a thought that you could try to use the XmlTextWriter to build your file instead? You'd need to Import the System.XML library to use this. I don't have the syntax at hand but it sounds like this may be what you need.
revelator

related questions