locked
Name 'Dts' is not declared RRS feed

  • Question

  • Hi,

    I am using the following script for reading the resultset returned by a variable using script task.

    But i am getting Name 'Dts' is not declared error.

    Can anyone help on dis?

    Imports System
    Imports System.Data
    Imports System.Math
    Imports Microsoft.SqlServer.Dts.Runtime
    Imports System.Xml
    Imports System.Data.OleDb

    Public Class ScriptMain

        Public Sub Main()

            Dim oleDA As New OleDbDataAdapter
            Dim dt As New DataTable
            Dim col As DataColumn
            Dim row As DataRow
            Dim sMsg As String

            oleDA.Fill(dt, Dts.Variables("dsVar").Value)

            For Each row In dt.Rows
                For Each col In dt.Columns
                    sMsg = sMsg & col.ColumnName & ": " & _
                           row(col.Ordinal).ToString & vbCrLf
                Next
                MsgBox(sMsg)
                sMsg = ""
            Next

            Dts.TaskResult = Dts.Results.Success

        End Sub

    End Class

    Thanks,

    visu

    Monday, June 4, 2012 2:04 PM

Answers

  • Looks like you changed the code that defines what scriptmain is - where did you get that code?

    Should be something like this:

    Imports System
    Imports System.Data
    Imports System.Math
    Imports Microsoft.SqlServer.Dts.Runtime
    Imports System.Xml
    Imports System.Data.OleDb
    <Microsoft.SqlServer.Dts.Tasks.ScriptTask.SSISScriptTaskEntryPointAttribute()> _
    <System.CLSCompliantAttribute(False)> _
    Partial Public Class ScriptMain
        Inherits Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
    
        Public Sub Main()
    
            Dim oleDA As New OleDbDataAdapter
            Dim dt As New DataTable
            Dim col As DataColumn
            Dim row As DataRow
            Dim sMsg As String
    
            oleDA.Fill(dt, Dts.Variables("dsVar").Value)
    
            For Each row In dt.Rows
                For Each col In dt.Columns
                    sMsg = sMsg & col.ColumnName & ": " & _
                           row(col.Ordinal).ToString & vbCrLf
                Next
                MsgBox(sMsg)
                sMsg = ""
            Next
    
            Dts.TaskResult = ScriptResults.Success
        End Sub
    Enum ScriptResults
    		Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success
    		Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
    	End Enum
    
    
    End Class
    



    Chuck Pedretti | Magenic – North Region | magenic.com



    • Edited by Chuck Pedretti Monday, June 4, 2012 2:17 PM
    • Proposed as answer by Eileen Zhao Wednesday, June 6, 2012 7:59 AM
    • Marked as answer by Eileen Zhao Monday, June 11, 2012 6:26 AM
    Monday, June 4, 2012 2:12 PM

All replies

  • Looks like you changed the code that defines what scriptmain is - where did you get that code?

    Should be something like this:

    Imports System
    Imports System.Data
    Imports System.Math
    Imports Microsoft.SqlServer.Dts.Runtime
    Imports System.Xml
    Imports System.Data.OleDb
    <Microsoft.SqlServer.Dts.Tasks.ScriptTask.SSISScriptTaskEntryPointAttribute()> _
    <System.CLSCompliantAttribute(False)> _
    Partial Public Class ScriptMain
        Inherits Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
    
        Public Sub Main()
    
            Dim oleDA As New OleDbDataAdapter
            Dim dt As New DataTable
            Dim col As DataColumn
            Dim row As DataRow
            Dim sMsg As String
    
            oleDA.Fill(dt, Dts.Variables("dsVar").Value)
    
            For Each row In dt.Rows
                For Each col In dt.Columns
                    sMsg = sMsg & col.ColumnName & ": " & _
                           row(col.Ordinal).ToString & vbCrLf
                Next
                MsgBox(sMsg)
                sMsg = ""
            Next
    
            Dts.TaskResult = ScriptResults.Success
        End Sub
    Enum ScriptResults
    		Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success
    		Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
    	End Enum
    
    
    End Class
    



    Chuck Pedretti | Magenic – North Region | magenic.com



    • Edited by Chuck Pedretti Monday, June 4, 2012 2:17 PM
    • Proposed as answer by Eileen Zhao Wednesday, June 6, 2012 7:59 AM
    • Marked as answer by Eileen Zhao Monday, June 11, 2012 6:26 AM
    Monday, June 4, 2012 2:12 PM
  • Inspect the reference to the DTS dll, perhaps it is either marked in yellow )broken) or missing (Microsoft.SqlServer.Dts.Runtime)

    Arthur My Blog

    Monday, June 4, 2012 2:13 PM
  • check this link for this error:

    http://support.microsoft.com/kb/955525

    Monday, June 4, 2012 2:15 PM