[python-win32] Re: DispatchWithEvents

Janez Jere janez.jere at void.si
Wed Jul 30 00:33:20 EDT 2003


>
> No idea really, but when I hashed together a sample DispatchWithEvents
> test a while ago, I had all of the callback functions' parameters
> default to pythoncom.Missing - for example:

Thanks, but this is not the solution. I thing that callbacks are ok.
because in the following example the same update statement works with
Execute method on connection,
but fails with execute on command.

So I think that I am dealing with an issue inside python COM libraries,
where object created with Dispatch is talking with object created with
DispatchWithEvents.

Same functionality is more than trivial in borland c++ builder or delphi, so
it must be more than simple in python too.

Example:

print '-'*30
conObj.Execute("update customers set companyname=companyname where
customerid='alfki'")
print '-'*30

cmd= Dispatch("ADODB.Command")
cmd.ActiveConnection = conObj
cmd.CommandText = "update customers set companyname=companyname where
customerid='alfki'"
rs, cnt = cmd.Execute()

Will produce following output:
------------------------------
OnWillExecute: update customers set companyname=companyname where
customerid='alfki'
OnExecuteComplete
------------------------------
OnWillExecute: update customers set companyname=companyname where
customerid='alfki'
OnExecuteComplete
Traceback (most recent call last):
  File "C:\cvs\jj\py\ado_events.py", line 42, in ?
    rs, cnt = cmd.Execute()
  File
"C:\usr\python\lib\site-packages\win32com\gen_py\EF53050B-882E-4776-B643-EDA
472E8E3F2x0x2x7.py", line 1822, in Execute
    return self._ApplyTypes_(5, 1, (9, 0), ((16396, 18), (16396, 17), (3,
49)), 'Execute', '{00000556-0000-0010-8000-00AA006D2EA4}',RecordsAffected,
Parameters, Options)
  File "C:\usr\python\lib\site-packages\win32com\client\__init__.py", line
445, in _ApplyTypes_
    return self._get_good_object_(apply(self._oleobj_.InvokeTypes, (dispid,
0, wFlags, retType, argTypes) + args), user, resultCLSID)
pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, 'Microsoft
OLE DB Provider for SQL Server', 'Command text was not set for the command
object.', None, 0, -2147217908), None)






More information about the Python-win32 mailing list