Microsoft KB Archive/271889

From BetaArchive Wiki
Knowledge Base


PRB: Error message: "Exception Access Violation 2147221499.Need to run the object to perform this operation" occurs when you run a DTS package in Microsoft Visual Basic code

Article ID: 271889

Article Last Modified on 12/28/2005



APPLIES TO

  • Microsoft SQL Server 7.0 Standard Edition
  • Microsoft SQL Server 2000 Standard Edition



This article was previously published under Q271889

SYMPTOMS

This article describes one possible reason as to why a Data Transformation Services (DTS) package created in Microsoft Visual Basic code may fail with an access violation (AV) error message.

When you create a DTS package by using the WITHEVENTS keyword, and you then run the DTS package from within Microsoft Visual Basic code, the package fails with an access violation and the following error message occurs:

Microsoft dts package provider generated code execution exception;
exception access violation 2147221499.Need to run the object to
perform this operation.

CAUSE

The following five events are associated with a DTS package when the DTS package is created by using the WITHEVENTS clause:

Private Sub <object>_OnError(ByVal EventSource As String, _
                                   ByVal ErrorCode As Long, _
                                   ByVal Source As String, _
                                   ByVal Description As String, _
                                   ByVal HelpFile As String, _
                                   ByVal HelpContext As Long, _
                                   ByVal IDofInterfaceWithError As String, _
                                   ByRef pbCancel As Boolean)

   Private Sub <object>_OnFinish(ByVal EventSource As String)

   Private Sub <object>_OnProgress(ByVal EventSource As String, _
                                   ByVal ProgressDescription As String, _
                                   ByVal PercentComplete As Long, _
                                   ByVal ProgressCountLow As Long, _
                                   ByVal ProgressCountHigh As Long)

   Private Sub <object>_OnQueryCancel(ByVal EventSource As String, _
                                       ByRef pbCancel As Boolean)

   Private Sub <object>_OnStart(ByVal EventSource As String)

If code for these events is not present, the error message described in the "Symptoms" section occurs.

For more information about these events, please see the following article in the Microsoft Knowledge Base:

221193 How to install Data Transformation Services (DTS) event handlers in Visual Basic


WORKAROUND

Note Implement the work around discussed in this section only if the DTS package is created by using the WITHEVENTS keyword.

To work around this problem:

  • Specify some dummy code for the five events.


-or-

  • Comment out the five events.

The sample code that follows demonstrates where an event handler is either commented out or valid code is specified:

Private Sub mobjDTS_OnFinish(ByVal EventSource As String)
' this is a comment.(or this piece should be replaced with the appropriate code for each of the five events.)
 End Sub

You would also have to make similar changes for the other four events.


Additional query words: DTS VB AV WITHEVENTS error message

Keywords: kbfix kbcodesnippet kbprb KB271889