COM problem calling DTS from vb.net
- From: Mike Voissem <MikeVoissem@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 9 Feb 2006 13:53:26 -0800
I was looking for a way to collect dts run information (errors, progress,
etc). I found this article
http://support.microsoft.com/default.aspx?scid=kb;en-us;321525
I did exactly as it suggested, and I receive an error at the following point:
cpContainer.FindConnectionPoint(guid, cpPoint)
The error is "no such interface supported"
I'm running Windows XP Pro with the latest service pack, and using VS2003
Below is the sample from that link above.
1. Open Visual Studio .NET, create a new Visual Basic Console Application
project, and then open the code window for the default Module1.
2. Set a reference to the DTSPackage Object (COM) Library , and insert the
following Imports statements at the top of the module:Imports
System.Runtime.InteropServices
Imports DTS
3. Insert the following code in the Sub Main procedure: 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("<server>", "<user>", "<password>", _
DTSSQLServerStorageFlags.DTSSQLStgFlag_Default, _
"", "", "", "<package name>", Nothing)
Console.WriteLine("PACKAGE EXECUTION BEGINNING")
pkg.Execute()
Console.WriteLine("PACKAGE EXECUTION COMPLETED")
Console.WriteLine("The package contained {0} steps.", _
pkg.Steps.Count.ToString)
pkg.UnInitialize()
pkg = Nothing
cpPoint.Unadvise(intCookie)
cpPoint = Nothing
cpContainer = Nothing
PES = Nothing
Catch exc As System.Runtime.InteropServices.COMException
Console.WriteLine(exc.Message)
Catch exc As Exception
Console.WriteLine(exc.Message)
Finally
Console.ReadLine()
End Try
4. Select or create a DTS package for use in this test, and then edit the
values as appropriate in the LoadFromSQLServer method for the server name,
user ID, password, and package name.
5. Under the End Module statement, insert the following events sink class to
handle the DTS Package events:Public Class PackageEventsSink
Implements DTS.PackageEvents
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
Console.WriteLine(" OnError in {0}; ErrorCode = {1}, Source = {2},"
& _
" Description = {3}", EventSource, ErrorCode, Source, Description)
End Sub
Overridable Overloads Sub OnFinish(ByVal EventSource As String) _
Implements DTS.PackageEvents.OnFinish
Console.WriteLine(" OnFinish in {0}", EventSource)
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
Console.WriteLine(" OnProgress in {0}; ProgressDescription = {1}", _
EventSource, ProgressDescription)
End Sub
Overridable Overloads Sub OnQueryCancel(ByVal EventSource As String, _
ByRef pbCancel As Boolean) Implements
DTS.PackageEvents.OnQueryCancel
If EventSource.Length > 0 Then
Console.WriteLine(" OnQueryCancel in {0}; pbCancel = {1}", _
EventSource, pbCancel.ToString)
Else
Console.WriteLine(" OnQueryCancel; pbCancel = {0}",
pbCancel.ToString)
End If
pbCancel = False
End Sub
Overridable Overloads Sub OnStart(ByVal EventSource As String) _
Implements DTS.PackageEvents.OnStart
Console.WriteLine(" OnStart in {0}", EventSource)
End Sub
End Class
6. Run the package and observe the sequence of steps and events. Click Enter
to close the console window and quit the program.
--
Mike Voissem
Lead Software Engineer
Donnelley Marketing
.
- Follow-Ups:
- RE: COM problem calling DTS from vb.net
- From: Mike Voissem
- RE: COM problem calling DTS from vb.net
- Prev by Date: Best Practice Shared connections
- Next by Date: Re: SQL 2005, DTS, problems, problems, problems, etc..
- Previous by thread: Best Practice Shared connections
- Next by thread: RE: COM problem calling DTS from vb.net
- Index(es):
Relevant Pages
|