[Tutor] ADO problem

János Juhász janos.juhasz at VELUX.com
Mon Jul 16 13:08:01 CEST 2007

Dear All,

I have a good sample about using ADO to reach windows active directory.

import win32com.client 
c = win32com.client.Dispatch("ADODB.Connection") 

SELECT name, description, department
where objectClass='user' and name='*.ferbau' and department = 'IT'
order by name

while not rs.EOF: 
    print rs.Fields[0].Value, rs.Fields[1].Value

It print the next result:
IT (u'\xc1kos Szab\xf3',)
IT (u'Szabolcs K\xe1m\xe1n',)

So rs.Fields[1] is a tuple.
I tried to turn it to get the first item from this tuple like this

while not rs.EOF: 
    print rs.Fields[0].Value, rs.Fields[1][0].Value

But it gives the next error 

Traceback (most recent call last):
  File "D:\devel\python\admin\AD_ADO.py", line 13, in ?
    print rs.Fields[0].Value, rs.Fields[1][0].Value
  File "c:\Python24\Lib\site-packages\win32com\client\dynamic.py", line 
228, in
    raise TypeError, "This object does not support enumeration"
TypeError: This object does not support enumeration

How can I print that unicode string?

János Juhász

More information about the Tutor mailing list