G
Guest
Hi,
I followed the the aricle
http://support.microsoft.com/default.aspx?scid=kb;en-us;321525 and was able
to execute a dts package
in vb.net. I replaced all the "Console.WriteLine" with "msgbox". The problem
I am having is that on my form I added a listbox control
and I created a sub that added entries to the list box
Public Sub addListItems(ByVal sItem As String)
ListBox1.Items.Add(sItem)
End Sub
Then I replaced all the "msgbox" with addListItems(<message>). But form the
PackageEventsSink class how do I execute the addListItems
on form1 to add the entries to the listbox. What I tried was creating an
event in the PackageEventsSink class
Public Event Message(ByVal sMessage As String)
and I tried to raise it like
Overridable Overloads Sub OnError(ByVal EventSource As String, _
ByVal ErrorCode As Integer, ByVal Source As String, _
ByVal Description As String, ByVal HelpFile As String, _
ByVal HelpContext As Integer, ByVal IDofInterfaceWithError As
String, _
ByRef pbCancel As Boolean) Implements DTS.PackageEvents.OnError
RaiseEvent Message("Error")
'MsgBox("Error")
End Sub
and form form1 I did the foll
declared Dim WithEvents PES As PackageEventsSink = New PackageEventsSink
and add
Private Sub PES_Message(ByVal sMessage As String) Handles PES.Message
ListBox1.Items.Add(sMessage)
Application.DoEvents()
End Sub
But when I run the program I get all the message boxes but then the program
hangs on the event. I get no error message. It just hangs.
This is the code
-------------class
Public Class PackageEventsSink
Implements DTS.PackageEvents
Public Event Message(ByVal sMessage As String)
Overridable Overloads Sub OnError(ByVal EventSource As String, _
ByVal ErrorCode As Integer, ByVal Source As String, _
ByVal Description As String, ByVal HelpFile As String, _
ByVal HelpContext As Integer, ByVal IDofInterfaceWithError As
String, _
ByRef pbCancel As Boolean) Implements DTS.PackageEvents.OnError
RaiseEvent Message("Error") <--------------here I believe is error.
'MsgBox("Error")
End Sub
Overridable Overloads Sub OnFinish(ByVal EventSource As String) _
Implements DTS.PackageEvents.OnFinish
MsgBox("On Finished")
End Sub
Overridable Overloads Sub OnProgress(ByVal EventSource As String, _
ByVal ProgressDescription As String, ByVal PercentComplete As
Integer, _
ByVal ProgressCountLow As Integer, ByVal ProgressCountHigh As
Integer) _
Implements DTS.PackageEvents.OnProgress
MsgBox("On Progress")
End Sub
Overridable Overloads Sub OnQueryCancel(ByVal EventSource As String, _
ByRef pbCancel As Boolean) Implements
DTS.PackageEvents.OnQueryCancel
If EventSource.Length > 0 Then
MsgBox("Query Cancel Yes")
Else
MsgBox("Query Cancel No")
End If
pbCancel = False
End Sub
Overridable Overloads Sub OnStart(ByVal EventSource As String) _
Implements DTS.PackageEvents.OnStart
MsgBox("On Start")
End Sub
End Class
--------------form 1
Dim WithEvents PES As PackageEventsSink = New PackageEventsSink
Dim pkg As DTS.Package
Try
pkg = New DTS.Package
'Begin - set up events sink
Dim cpContainer As UCOMIConnectionPointContainer
cpContainer = CType(pkg, UCOMIConnectionPointContainer)
Dim cpPoint As UCOMIConnectionPoint
'Dim PES As PackageEventsSink = New PackageEventsSink
Dim guid As Guid = _
New Guid("10020605-EB1C-11CF-AE6E-00AA004A34D5")
cpContainer.FindConnectionPoint(guid, cpPoint)
Dim intCookie As Integer
cpPoint.Advise(PES, intCookie)
'End - set up events sink
pkg.LoadFromSQLServer("nysvrprod01", "", "",
DTS.DTSSQLServerStorageFlags.DTSSQLStgFlag_Default, , , , "New Package")
'MsgBox("PACKAGE EXECUTION BEGINNING")
addListItems("PACKAGE EXECUTION BEGINNING")
pkg.Execute()
'MsgBox("PACKAGE EXECUTION COMPLETED")
addListItems("PACKAGE EXECUTION COMPLETED")
'MsgBox("The package contained steps." & pkg.Steps.Count.ToString)
addListItems("The package contained steps." &
pkg.Steps.Count.ToString)
pkg.UnInitialize()
pkg = Nothing
cpPoint.Unadvise(intCookie)
cpPoint = Nothing
cpContainer = Nothing
PES = Nothing
Catch exc As Exception
MsgBox(exc.Message)
Finally
pkg = Nothing
'Debug.ReadLine()
End Try
Private Sub PES_Message(ByVal sMessage As String) Handles PES.Message
addListItems(sMessage)
Application.DoEvents()
End Sub
I followed the the aricle
http://support.microsoft.com/default.aspx?scid=kb;en-us;321525 and was able
to execute a dts package
in vb.net. I replaced all the "Console.WriteLine" with "msgbox". The problem
I am having is that on my form I added a listbox control
and I created a sub that added entries to the list box
Public Sub addListItems(ByVal sItem As String)
ListBox1.Items.Add(sItem)
End Sub
Then I replaced all the "msgbox" with addListItems(<message>). But form the
PackageEventsSink class how do I execute the addListItems
on form1 to add the entries to the listbox. What I tried was creating an
event in the PackageEventsSink class
Public Event Message(ByVal sMessage As String)
and I tried to raise it like
Overridable Overloads Sub OnError(ByVal EventSource As String, _
ByVal ErrorCode As Integer, ByVal Source As String, _
ByVal Description As String, ByVal HelpFile As String, _
ByVal HelpContext As Integer, ByVal IDofInterfaceWithError As
String, _
ByRef pbCancel As Boolean) Implements DTS.PackageEvents.OnError
RaiseEvent Message("Error")
'MsgBox("Error")
End Sub
and form form1 I did the foll
declared Dim WithEvents PES As PackageEventsSink = New PackageEventsSink
and add
Private Sub PES_Message(ByVal sMessage As String) Handles PES.Message
ListBox1.Items.Add(sMessage)
Application.DoEvents()
End Sub
But when I run the program I get all the message boxes but then the program
hangs on the event. I get no error message. It just hangs.
This is the code
-------------class
Public Class PackageEventsSink
Implements DTS.PackageEvents
Public Event Message(ByVal sMessage As String)
Overridable Overloads Sub OnError(ByVal EventSource As String, _
ByVal ErrorCode As Integer, ByVal Source As String, _
ByVal Description As String, ByVal HelpFile As String, _
ByVal HelpContext As Integer, ByVal IDofInterfaceWithError As
String, _
ByRef pbCancel As Boolean) Implements DTS.PackageEvents.OnError
RaiseEvent Message("Error") <--------------here I believe is error.
'MsgBox("Error")
End Sub
Overridable Overloads Sub OnFinish(ByVal EventSource As String) _
Implements DTS.PackageEvents.OnFinish
MsgBox("On Finished")
End Sub
Overridable Overloads Sub OnProgress(ByVal EventSource As String, _
ByVal ProgressDescription As String, ByVal PercentComplete As
Integer, _
ByVal ProgressCountLow As Integer, ByVal ProgressCountHigh As
Integer) _
Implements DTS.PackageEvents.OnProgress
MsgBox("On Progress")
End Sub
Overridable Overloads Sub OnQueryCancel(ByVal EventSource As String, _
ByRef pbCancel As Boolean) Implements
DTS.PackageEvents.OnQueryCancel
If EventSource.Length > 0 Then
MsgBox("Query Cancel Yes")
Else
MsgBox("Query Cancel No")
End If
pbCancel = False
End Sub
Overridable Overloads Sub OnStart(ByVal EventSource As String) _
Implements DTS.PackageEvents.OnStart
MsgBox("On Start")
End Sub
End Class
--------------form 1
Dim WithEvents PES As PackageEventsSink = New PackageEventsSink
Dim pkg As DTS.Package
Try
pkg = New DTS.Package
'Begin - set up events sink
Dim cpContainer As UCOMIConnectionPointContainer
cpContainer = CType(pkg, UCOMIConnectionPointContainer)
Dim cpPoint As UCOMIConnectionPoint
'Dim PES As PackageEventsSink = New PackageEventsSink
Dim guid As Guid = _
New Guid("10020605-EB1C-11CF-AE6E-00AA004A34D5")
cpContainer.FindConnectionPoint(guid, cpPoint)
Dim intCookie As Integer
cpPoint.Advise(PES, intCookie)
'End - set up events sink
pkg.LoadFromSQLServer("nysvrprod01", "", "",
DTS.DTSSQLServerStorageFlags.DTSSQLStgFlag_Default, , , , "New Package")
'MsgBox("PACKAGE EXECUTION BEGINNING")
addListItems("PACKAGE EXECUTION BEGINNING")
pkg.Execute()
'MsgBox("PACKAGE EXECUTION COMPLETED")
addListItems("PACKAGE EXECUTION COMPLETED")
'MsgBox("The package contained steps." & pkg.Steps.Count.ToString)
addListItems("The package contained steps." &
pkg.Steps.Count.ToString)
pkg.UnInitialize()
pkg = Nothing
cpPoint.Unadvise(intCookie)
cpPoint = Nothing
cpContainer = Nothing
PES = Nothing
Catch exc As Exception
MsgBox(exc.Message)
Finally
pkg = Nothing
'Debug.ReadLine()
End Try
Private Sub PES_Message(ByVal sMessage As String) Handles PES.Message
addListItems(sMessage)
Application.DoEvents()
End Sub