Discussion:
[python-win32] Opening Access (mdb) database: ADODB.Connection - Der Provider kann nicht gefunden werden
Niemann, Hartmut
2015-04-20 13:49:58 UTC
Permalink
Hello!

I try to open and write an (Access 2000) mdb file, and get an error I cannot interpret.

This code as worked in the past (two months ago) and works without modification on a different PC of a colleague, so chances are
my configuration misses a simple thing, a software package (update) or something other trivial.

My System is Win7,
Python 2.7.9 (default, Dec 10 2014, 12:28:03) [MSC v.1500 64 bit (AMD64)] on win32,
pywin32-219.win-amd64-py2.7.exe
Microsoft Office Access 2007 (12.0.6696.1000) SP3 MSO (12.0.6718.5000)

Could this be some 32-bit vs. 64-bit thing? (ATM I can not check whether my colleague still uses an older (32bit?) installation.)

this is the source
--------------------
try:
print "Open ADOB.Connection"
ado = win32com.client.Dispatch("ADODB.Connection")
connectionstring = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=\"%s\"" % filename # Access 2003
#connectionstring = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=\"%s\"" % filename # Access 2007
print "Open ADOB.Connection with '%s'" % connectionstring
ado.Open(connectionstring)
except pythoncom.com_error, (hr, msg, exc, arg): # pylint: disable=E1101
print "The Access call failed with code %d: %s" % (hr, msg)
if exc is None:
print "There is no extended error information"
else:
wcode, source, text, helpFile, helpId, scode = exc
print "The source of the error is", source
print "The error message is", text
print "More info can be found in %s (id=%d)" % (helpFile, helpId)
raise
return ado
------------
This is the result
------------------
Open ADOB.Connection with 'Provider=Microsoft.Jet.OLEDB.4.0; Data Source="out\Stoermeld-B97.mdb"'
The Access call failed with code -2147352567: Ausnahmefehler aufgetreten.
The source of the error is ADODB.Connection
The error message is Der Provider kann nicht gefunden werden. Möglicherweise ist er nicht richtig installiert worden.
More info can be found in C:\WINDOWS\HELP\ADO270.CHM (id=1240655)
Traceback (most recent call last):
File "D:\PRJ\DPS\bin\stoerungsmeldungen.py", line 1117, in <module>
options.opcid)
File "D:\PRJ\DPS\bin\stoerungsmeldungen.py", line 893, in write_oms
myoms = omsdatabase.OMS(omsname)
File "D:\PRJ\DPS\bin\omsdatabase.py", line 225, in __init__
self._ADOconnectionObject = access_open(filename)
File "D:\PRJ\DPS\bin\omsdatabase.py", line 183, in access_open
ado.Open(connectionstring)
File "C:\Python27\lib\site-packages\win32com\gen_py\B691E011-1797-432E-907A-4D8C69339129x0x6x1.py", line 3523, in Open
, UserID, Password, Options)
File "C:\Python27\lib\site-packages\win32com\client\__init__.py", line 459, in _ApplyTypes_
self._oleobj_.InvokeTypes(dispid, 0, wFlags, retType, argTypes, *args),
pywintypes.com_error: (-2147352567, 'Ausnahmefehler aufgetreten.', (0, u'ADODB.Connection', u'Der Provider kann nicht gefunden werden. M\xf6glicherweise ist er
nicht richtig installiert worden.', u'C:\\WINDOWS\\HELP\\ADO270.CHM', 1240655, -2146824582), None)
---------
----
if I try the ACE 12 string that should (according to some googling) belong to the JET module of Access 2007
which is installed on the PC (opening the mdb with double click works just fine), I get:
-----
Open ADOB.Connection with 'Provider=Microsoft.ACE.OLEDB.12.0;Data Source="out\Stoermeld-B97.mdb"'
The Access call failed with code -2147352567: Ausnahmefehler aufgetreten.
The source of the error is ADODB.Connection
The error message is Der Provider kann nicht gefunden werden. Möglicherweise ist er nicht richtig installiert worden.
More info can be found in C:\WINDOWS\HELP\ADO270.CHM (id=1240655)
Traceback (most recent call last):
File "D:\PRJ\DPS\bin\stoerungsmeldungen.py", line 1117, in <module>
options.opcid)
File "D:\PRJ\DPS\bin\stoerungsmeldungen.py", line 893, in write_oms
myoms = omsdatabase.OMS(omsname)
File "D:\PRJ\DPS\bin\omsdatabase.py", line 225, in __init__
self._ADOconnectionObject = access_open(filename)
File "D:\PRJ\DPS\bin\omsdatabase.py", line 183, in access_open
ado.Open(connectionstring)
File "C:\Python27\lib\site-packages\win32com\gen_py\B691E011-1797-432E-907A-4D8C69339129x0x6x1.py", line 3523, in Open
, UserID, Password, Options)
File "C:\Python27\lib\site-packages\win32com\client\__init__.py", line 459, in _ApplyTypes_
self._oleobj_.InvokeTypes(dispid, 0, wFlags, retType, argTypes, *args),
pywintypes.com_error: (-2147352567, 'Ausnahmefehler aufgetreten.', (0, u'ADODB.Connection', u'Der Provider kann nicht gefunden werden. M\xf6glicherweise ist er
nicht richtig installiert worden.', u'C:\\WINDOWS\\HELP\\ADO270.CHM', 1240655, -2146824582), None)
------

I must admit that I have little knowledge about COM and wrote this code
by copying and modyfiying code examples I found.
It worked rather well in the past, but now it fails for me (and still works for other people).

What can I try next?

Is this the best way to access an mdb database from python (2.7) or what would
be preferred?


Mit freundlichen Grüßen
Dr. Hartmut Niemann

Siemens AG
Mobility
MO MLT LM EN CCI 1
Werner-von-Siemens-Str. 67
91052 Erlangen, Deutschland
Tel.: +49 9131 7-34264
Fax: +49 9131 7-26254
mailto:***@siemens.com

Siemens Aktiengesellschaft: Vorsitzender des Aufsichtsrats: Gerhard Cromme; Vorstand: Joe Kaeser, Vorsitzender; Roland Busch, Lisa Davis, Klaus Helmrich, Janina Kugel, Siegfried Russwurm, Ralf P. Thomas; Sitz der Gesellschaft: Berlin und München, Deutschland; Registergericht: Berlin Charlottenburg, HRB 12300, München, HRB 6684; WEEE-Reg.-Nr. DE 23691322
Rod Person
2015-04-20 14:15:14 UTC
Permalink
Post by Niemann, Hartmut
this is the source
--------------------
print "Open ADOB.Connection"
ado = win32com.client.Dispatch("ADODB.Connection")
connectionstring = "Provider=Microsoft.Jet.OLEDB.4.0; Data
Source=\"%s\"" % filename # Access 2003
#connectionstring = "Provider=Microsoft.ACE.OLEDB.12.0;Data
Source=\"%s\"" % filename # Access 2007
print "Open ADOB.Connection with '%s'" % connectionstring
ado.Open(connectionstring)
except pythoncom.com_error, (hr, msg, exc, arg): # pylint: disable=E1101
print "The Access call failed with code %d: %s" % (hr, msg)
print "There is no extended error information"
wcode, source, text, helpFile, helpId, scode = exc
print "The source of the error is", source
print "The error message is", text
print "More info can be found in %s (id=%d)" % (helpFile, helpId)
raise
return ado
------------
This is the result
------------------
Open ADOB.Connection with 'Provider=Microsoft.Jet.OLEDB.4.0; Data
Source="out\Stoermeld-B97.mdb"'
The Access call failed with code -2147352567: Ausnahmefehler aufgetreten.
The source of the error is ADODB.Connection
The error message is Der Provider kann nicht gefunden werden.
Möglicherweise ist er nicht richtig installiert worden.
I don't read or speak German so my thought on what this error says could
be wrong but, it looks like it is saying that the Data Provider is
missing. If so, you need Jet.OLEDB.4.0 providers install on the
machine. They should be install with Access 2000 but am assume you just
have the mdb file. Might want to check the MS site to see if you can
download the provider without Access 2000.
--
Rod

"Times are bad. Children no longer obey their parents, and everyone is writing a book."
-- Marcus Tullius Cicero(106 BC - 43 BC)
Vernon D. Cole
2015-04-20 22:46:53 UTC
Permalink
I also cannot read German, and also I guess that you do not have the
correct provider. There are numerous difficulties with 64 vs 32 bit
providers for Access (Jet) databases.

More information about providers can be found on the links in
http://adodbapi.sourceforge.net/quick_reference.pdf

I in reviewing my answer, I find that the link to the "hacked" 12.0
versions of the provider at http://shares.digvil.info/redis/ was broken, so
I repaired the site.
--
Vernon Cole
Post by Niemann, Hartmut
this is the source
--------------------
print "Open ADOB.Connection"
ado = win32com.client.Dispatch("ADODB.Connection")
connectionstring = "Provider=Microsoft.Jet.OLEDB.4.0; Data
Source=\"%s\"" % filename # Access 2003
#connectionstring = "Provider=Microsoft.ACE.OLEDB.12.0;Data
Source=\"%s\"" % filename # Access 2007
print "Open ADOB.Connection with '%s'" % connectionstring
ado.Open(connectionstring)
except pythoncom.com_error, (hr, msg, exc, arg): # pylint: disable=E1101
print "The Access call failed with code %d: %s" % (hr, msg)
print "There is no extended error information"
wcode, source, text, helpFile, helpId, scode = exc
print "The source of the error is", source
print "The error message is", text
print "More info can be found in %s (id=%d)" % (helpFile, helpId)
raise
return ado
------------
This is the result
------------------
Open ADOB.Connection with 'Provider=Microsoft.Jet.OLEDB.4.0; Data
Source="out\Stoermeld-B97.mdb"'
The Access call failed with code -2147352567: Ausnahmefehler aufgetreten.
The source of the error is ADODB.Connection
The error message is Der Provider kann nicht gefunden werden.
Möglicherweise ist er nicht richtig installiert worden.
I don't read or speak German so my thought on what this error says could
be wrong but, it looks like it is saying that the Data Provider is
missing. If so, you need Jet.OLEDB.4.0 providers install on the machine.
They should be install with Access 2000 but am assume you just have the mdb
file. Might want to check the MS site to see if you can download the
provider without Access 2000.
--
Rod
“Times are bad. Children no longer obey their parents, and everyone is writing a book.”
-- Marcus Tullius Cicero(106 BC - 43 BC)
_______________________________________________
python-win32 mailing list
https://mail.python.org/mailman/listinfo/python-win32
Vernon D. Cole
2015-04-21 00:21:41 UTC
Permalink
On Mon, Apr 20, 2015 at 7:49 AM, Niemann, Hartmut <
Post by Niemann, Hartmut
[...]
Is this the best way to access an mdb database from python (2.7) or what would
be preferred?
Rather than programming ADO by COM interface, you might find it easier or
more convenient to use the standard Python db-api interface provided by
sourceforge.net/projects/adodbapi . It uses the same providers that you
are struggling with now (it calls the ADO COM interface for you) so it will
not help with your existing problem, unfortunately.

Loading...