problem with SQL-DMO and win32com (and a workaround)

Geoff Talvola gtalvola at
Fri Nov 2 00:07:15 CET 2001

SQL-DMO is a COM library that you use to administer MS SQL Server 
programmatically.  I was happily using the version of SQL-DMO that comes 
with SQL Server 7.0 with no problems.  Now that I upgraded to the SQL-DMO 
that comes with SQL Server 2000, I get the following error (using Python 
2.1 and win32all 139 or 140):

 >>> from win32com.client import gencache
 >>> s = gencache.EnsureDispatch('SQLDMO.SQLServer')
 >>> s.Connect('DBSERVER')
 >>> s.Databases('MyDatabase')
Traceback (most recent call last):
   File "<interactive input>", line 1, in ?
line 70, in __call__
     if ret is not None: ret = win32com.client.Dispatch(ret, '__call__', 
'{10020300-E260-11CF-AE68-00AA004A34D5}', UnicodeToString=0)
   File "win32com\client\", line 95, in Dispatch
     return __WrapDispatch(dispatch, userName, resultCLSID, typeinfo, 
UnicodeToString, clsctx)
   File "win32com\client\", line 35, in __WrapDispatch
     klass = gencache.GetClassForCLSID(resultCLSID)
   File "win32com\client\", line 131, in GetClassForCLSID
     mod = GetModuleForCLSID(clsid)
   File "win32com\client\", line 179, in GetModuleForCLSID
line 48, in ?
line 23, in ?
     class _Database2(DispatchBaseClass):
NameError: name 'DispatchBaseClass' is not defined

If I instead use:

 >>> s = gencache.EnsureDispatch('SQLDMO.SQLServer', 0)

it works without errors.  So that's the workaround.  But it's slower and 
takes more memory.

If anyone (i.e. Mark Hammond :-)) would like to try to track this down, I 
can zip up and email the broken auto-generated files.  Just let me know.


- Geoff Talvola
   gtalvola at

More information about the Python-list mailing list