This is another one of those things I wish Google had told me so I wouldn’t have had to figure it out myself. Unless you were specifically looking for this information, it’ll probably be completely useless to you, so by all means skip this post and go read something more interesting.
Over the last few days, I’ve been implementing a tool at work using VB6 that uses Microsoft’s SQL-DMO component to build a nice database installer and upgrader for the software I’m writing. Before upgrading a database, I use SQL-DMO’s Backup object to create a backup of it. Since these databases, in a production environment, can get pretty huge, I also implemented an event handler for the Backup object’s PercentComplete event, which fires at a set interval and allows you to update a progress bar with the progress of the backup operation.
The problem I ran into is that, while the backup operation itself runs just fine, the Backup object throws this nasty error as soon as the operation completes:
Run-time error '-2147221499 (80040005)': [SQL-DMO]Code execution exception: EXCEPTION_ACCESS_VIOLATION
After much fruitless perusing of documentation and Googling, I eventually stumbled upon the discovery that the errors stop occurring if you simply implement event handlers for all of the Backup object’s events, rather than only implementing the handlers you’re using. As soon as I added those empty event handlers, things started working without a hitch.
As an ironic sidenote, my Google searching turned up a report that Microsoft’s own SQL Server Enterprise Manager (which also uses the SQL-DMO component) suffers from the same problem.
Comments
Man, you save me...
Thanks for the article, I just had the same problem and now my backup module is out of problems.
You Da Man!
Thanks! I banged my head against the wall a few months back on this one. Ended up just adding "on error goto next", which I hate. This works perfect!
No title
Thank you! Thank you! Thank you! Thank you! Thank you!
Thank you, that was helpful.
-Steve
Thanks for your help
I just hit upon that error which puzzled me. Two seconds of Googling revealed your post that allowed me to apply the unexpected solution. Yet again poor Microsoft code, still buggy even with SQL Server 2005 SQL-DMO.
Maybe of interest
I has the exact same problem, but all the event handlers for the backup object were implemented. After much grief I discovered that it was caused by a recent version of msvcr71.dll in the windows system folder. When I copied an older version back it worked fine.
Indeed...
Thanks to this post I ended up spending only a few moments solving an error that could have consumed many good hours of my time. More power to you:)
You helped me big time! Thanks a lot!!
-Alex