ADO Events with win32com

Paul Moore paul.moore at
Tue Jul 24 08:01:39 EDT 2001

On Sat, 21 Jul 2001 18:24:59 +0200, Paul Moore <gustav at>

>On 21 Jul 2001 07:40:17 -0700, nmack at (angusm) wrote:
>>I think the problem is that COM (or ADO?)requires you to define all
>>the event handlers for the interface in your class:
>>"All the event handlers in the ConnectionEvent ... must be
>>implemented, regardless of whether you actually use events. " MSDN
>I'll try it, but I'm surprised. I didn't need to do this for a different object
>I tested the event code on. That has many events, and I only implemented the one
>I used. I assumes that the win32com stuff did its magic, and made it work...
>Nevertheless, thanks for the suggestion - I'll try it.

It did get rid of the "User has cancelled the operation" error - on a bit more
investigation, it looks like I needed to implement the OnWillConnect event as
well as the OnConnectComplete event. This is odd... The ADO docs state that
the WillConnect event gets passed an "adStatus" parameter set to adStatusOK -
to cancel the connection, the parameter should be set to adStatusCancel. For
some reason, if I implement

    def OnWillConnect(self, ConnectionString, UserID,
                      Password, Options, adStatus,

this works, but if I *don't* implement this, whatever win32com does behind the
scenes doesn't work.

However, I now don't ever seem to receive the OnConnectComplete event. This
may be an ADO issue, but I've tested it in VB and it works as documented, so I
suspect something with the Python side...

Any suggestions?

More information about the Python-list mailing list