Win32 Com + ADO: How to compare the result of a recordset to 'nothing'

Giles Brown giles_brown at hotmail.com
Mon Sep 15 17:07:22 EDT 2003


"Felix McAllister" <felix_mcallister at hotmail.com> wrote in message news:<tvj9b.31786$pK2.53500 at news.indigo.ie>...
> Hi,
> When using win32com.client, how do you test for a 'nothing' com object as you can in VB? I have an example here when using ADO to loop over multiple recordsets returned from a query. I get the following error:
> 
> Traceback (most recent call last):
>   File "C:\dev\python\MySamples\dbtest.py", line 14, in ?
>     rs.MoveFirst()
>   File "C:\Python23\lib\site-packages\win32com\client\dynamic.py", line 460, in __getattr__
>     raise AttributeError, "%s.%s" % (self._username_, attr)
> AttributeError: <unknown>.MoveFirst
> 
> I'm assuming that after the result of rs.NextRecordSet is invalid somehow (it shouldn't be, BTW, as a similar loop runs fine in VB). 
> 
> In Perl, I'd just use : if (defined($rs)....
> 
> Any help appreciated,
This is just a guess, but is it anything to do with NextRecordset
returning a tuple (recordset, records affected)?

(Don't think that should end up being wrapped in a
win32com.client.dynamic
wrapper though?)

You could try putting some print statements into
win32com.client.dynamic
to see exactly what you're getting back.

Good luck,
Giles Brown




More information about the Python-list mailing list