Discussion:
Name 'Dts' not declared.
(too old to reply)
unknown
2009-11-17 10:53:24 UTC
Permalink
Hi all,

I'm a SSIS newbie and I'm attempting to set up a simple Script task.In the Edit Script Task, I have the VB code shown below.

However, I keep getting this error that states "Name 'Dts' not declared". Any pointers on how I can resolve this would be greatly appreciated. Thanks.

Public Sub Main()
'
' Add your code here
'
Dim XMLString As String = " "



XMLString = Dts.Variables("XMLVariable").Value.ToString.Replace("<ROOT>", "").Replace("</ROOT>", "")
XMLString = "<?xml version=""1.0"" ?>" + XMLString

GenerateXmlFile("C:\\MusicCollection.xml", XMLString)

End Sub

Public Sub GenerateXmlFile(ByVal filePath As String, ByVal fileContents As String)

Dim objStreamWriter As IO.StreamWriter
Try

objStreamWriter = New IO.StreamWriter(filePath)

objStreamWriter.Write(fileContents)

objStreamWriter.Close()

Catch Excep As Exception

MsgBox(Excep.Message)

End Try
Dts.TaskResult = Dts.Results.Success
End Sub


EggHeadCafe - Software Developer Portal of Choice
MDI Inter-Form Communication with Events
http://www.eggheadcafe.com/tutorials/aspnet/0a957f0d-585a-4a3c-935f-20ce4f44f644/mdi-interform-communicat.aspx
Todd C
2009-11-17 13:48:11 UTC
Permalink
Ryan:
Are you placing your script task on the Control Flow, or in a Data Flow?

I think it makes a difference which Imports statements the Script adds
automatically. Try one of each and examine the pre-defined parts.

HTH
=====
Todd C
Post by unknown
Hi all,
I'm a SSIS newbie and I'm attempting to set up a simple Script task.In the Edit Script Task, I have the VB code shown below.
However, I keep getting this error that states "Name 'Dts' not declared". Any pointers on how I can resolve this would be greatly appreciated. Thanks.
Public Sub Main()
'
' Add your code here
'
Dim XMLString As String = " "
XMLString = Dts.Variables("XMLVariable").Value.ToString.Replace("<ROOT>", "").Replace("</ROOT>", "")
XMLString = "<?xml version=""1.0"" ?>" + XMLString
GenerateXmlFile("C:\\MusicCollection.xml", XMLString)
End Sub
Public Sub GenerateXmlFile(ByVal filePath As String, ByVal fileContents As String)
Dim objStreamWriter As IO.StreamWriter
Try
objStreamWriter = New IO.StreamWriter(filePath)
objStreamWriter.Write(fileContents)
objStreamWriter.Close()
Catch Excep As Exception
MsgBox(Excep.Message)
End Try
Dts.TaskResult = Dts.Results.Success
End Sub
EggHeadCafe - Software Developer Portal of Choice
MDI Inter-Form Communication with Events
http://www.eggheadcafe.com/tutorials/aspnet/0a957f0d-585a-4a3c-935f-20ce4f44f644/mdi-interform-communicat.aspx
.
Loading...