Python, Access and win32com

Geoff Talvola gtalvola at
Thu Feb 22 15:23:30 EST 2001

Will Newton wrote:

> I have been struggling to get MS Access 97 and the JET database engine to
> work with Active State Python and the win32com extensions.
> If I run I get the following error:
> (Unfortuantely ASPython doesn't seem to have saved the log, why, I have no
> idea)
> com_error(-(a large number, INT_MAX?),CLASS_E_NOTLICENSED...)

It might be the problem described in in which case you can use the FixDAO function in the attached module to fix the problem.


- Geoff Talvola
  Parlance Corporation
  gtalvola at

-------------- next part --------------
import win32api, win32con, win32com.client, win32com.client.gencache

def FixDAO():
    If DAO.DBEngine.35 cannot be created, this function will fix up the
    licensing Registry variables necessary so that it can be created.
        key = win32api.RegOpenKeyEx(win32con.HKEY_CLASSES_ROOT,'LICENSES\\F4FC596D-DFFE-11CF-9551-00AA00A3DC45',0,win32con.KEY_SET_VALUE|win32con.KEY_READ)
        key = win32api.RegCreateKey(win32con.HKEY_CLASSES_ROOT,'LICENSES\\F4FC596D-DFFE-11CF-9551-00AA00A3DC45')
    if win32api.RegQueryValue(key,'') != 'mbmabptebkjcdlgtjmskjwtsdhjbmkmwtrak':
        win32api.RegSetValue(key, '', win32con.REG_SZ, 'mbmabptebkjcdlgtjmskjwtsdhjbmkmwtrak')

def DAO():
    Create and return a DAO.DBEngine.35 object using early-bound automation
    # make sure that the makepy imformation has been generated
    win32com.client.gencache.EnsureModule('{00025E01-0000-0000-C000-000000000046}', 0, 4, 0)
    # Try to create the DAO object; if it fails, fix the licensing and try again.
        return win32com.client.Dispatch('DAO.DBEngine.35')
        return win32com.client.Dispatch('DAO.DBEngine.35')

More information about the Python-list mailing list