COM callbacks in Python

Roger Upole rupole at hotmail.com
Fri Mar 24 01:20:33 EST 2006


"Dan" <danbrwn at gmail.com> wrote in message news:1143148427.605756.205120 at g10g2000cwb.googlegroups.com...
>I need to register for a COM  callback under Windows. I am using an ADO
> recordset interface like this:
>
> import win32com.client
> import time
> connect = win32com.client.Dispatch("ADODB.Connection")
> recordset = win32com.client.Dispatch("ADODB.Recordset")
> connect.Open("Driver={SQLServer};Server=devserver;Database=VidVisitation;UID=sa;PWD=;")
> datestring = time.strftime("%m/%d/%Y")
> sql = "Select * from VisSchedule where SDATE='" + datestring +"'"
> recordset.Open(sql,connect)
>
> Now I want to receive events for the recordset when the recordset
> changes. Here is the IDL for the event:
> [id(0x0000000e)]
> HRESULT RecordsetChangeComplete(
>                [in] EventReasonEnum adReason,
>                [in] Error* pError,
>                [in, out] EventStatusEnum* adStatus,
>                [in] _Recordset* pRecordset);
>
> How do I wire up the recordset I have created to receive this event?
>
Use win32com.client.DispatchWithEvents, and create a class that
implements the event methods defined for the Recordset object.
You can find prototypes for the methods in the makepy-generated
file.

          Roger




----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---



More information about the Python-list mailing list