ExceptionMessageBox

  • I am trying to get the Exception Message Box to work in a script task in SSIS.

     

    I am using the example from http://msdn2.microsoft.com/en-us/library/ms166340.aspx almost verbatum.

     

    Imports System

    Imports System.Data

    Imports System.Math

    Imports Microsoft.SqlServer.Dts.Runtime

    Imports Microsoft.SqlServer.MessageBox

     

       Public Sub Main()

            '

            ' Define the message and caption to display.

            Dim str As String = "Do you want to push to Production?"

            Dim caption As String = "Zip Push"

            Dim var As Variables

     

            ' Show the exception message box with Yes and No buttons.

            Dim box As ExceptionMessageBox = New ExceptionMessageBox(str, caption)

            box.DefaultButton = ExceptionMessageBoxDefaultButton.Button2

            box.Symbol = ExceptionMessageBoxSymbol.Question

            box.Buttons = ExceptionMessageBoxButtons.YesNo

     

            'box.SetButtonText("Yes", "No", "Cancel")

     

            If Windows.Forms.DialogResult.Yes = box.Show(CType(Me,Windows.Forms.IWin32Window)) Then

                Dts.Variables("Production").Value = True

            End If

     

            '

            Dts.TaskResult = Dts.Results.Success

        End Sub

     

    And yet all I get is the following error

     

    Unable to cast object of type 'ScriptTask_bc7fa8cd8b3c4f4d96407f2b13927e0f.ScriptMain' to type 'System.Windows.Forms.IWin32Window'.

     

    Has anyone gotten this to work?

  • I found a way to make it work

     

    Imports System

    Imports System.Data

    Imports System.Math

    Imports Microsoft.SqlServer.Dts.Runtime

    Imports Microsoft.SqlServer.MessageBox

     

       Public Sub Main()

            '

            ' Define the message and caption to display.

            Dim str As String = "Do you want to push to Production?"

            Dim caption As String = "Zip Push"

            Dim var As Variables

            Dim win As Windows.Forms.IWin32Window

     

            ' Show the exception message box with Yes and No buttons.

            Dim box As ExceptionMessageBox = New ExceptionMessageBox(str, caption)

            box.DefaultButton = ExceptionMessageBoxDefaultButton.Button2

            box.Symbol = ExceptionMessageBoxSymbol.Question

            box.Buttons = ExceptionMessageBoxButtons.YesNo

     

            'box.SetButtonText("Yes", "No", "Cancel")

     

          If Windows.Forms.DialogResult.Yes = box.Show(win) Then

               Dts.Variables("Production").Value = True

            End If

     

            '

            Dts.TaskResult = Dts.Results.Success

        End Sub

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply