473,396 Members | 1,998 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Help with raising an event form class

Hi,
I followed the the aricle
http://support.microsoft.com/default...b;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

Nov 22 '05 #1
0 809

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: serge calderara | last post by:
Dear all, I have a class wich is raising events as normally it should do. having a form in the same assembly wich is catching those events works fne. Raise events gets catch normaly within the...
6
by: Dan | last post by:
I've created a pocketpc app which has a startup form containing a listview. The form creates an object which in turn creates a System.Threading.Timer. It keeps track of the Timer state using a...
22
by: Jeff Louie | last post by:
Well I wonder if my old brain can handle threading. Dose this code look reasonable. Regards, Jeff using System; using System.Diagnostics; using System.IO; using System.Threading;
1
by: Michael D. Reed | last post by:
I am using the help class to display a simple help file. I generated the help file using Word and saving it as a single page Web page (.mht extension). I show the help file with the following...
4
by: serge calderara | last post by:
Dear all, I have a class wich is raising events as normally it should do. having a form in the same assembly wich is catching those events works fne. Raise events gets catch normaly within the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.