大家好。
我使用的是 windows 7 x64 ,python33 x64, win32com x64
我在连接 access 数据库的时候总是报错:
Traceback (most recent call last):
File "<interactive input>", line 1, in <module>
File "<COMObject ADODB.Connection>", line 3, in Open
File "D:\Python33\lib\site-packages\win32com\client\dynamic.py", line 282, in _ApplyTypes_
result = self._oleobj_.InvokeTypes(*(dispid, LCID, wFlags, retType, argTypes) + args)
pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, 'ADODB.Connection', 'Provider cannot be found. It may not be properly installed.', 'C:\\Windows\\HELP\\ADO270.CHM', 1240655, -2146824582), None)
我的代码:
>>> import win32com.client
>>> import os,sys,string
>>> conn = win32com.client.Dispatch(r'ADODB.Connection')
>>> DSN = 'PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=a.mdb;'
>>> conn.Open(DSN)
Traceback (most recent call last):
File "<interactive input>", line 1, in <module>
File "<COMObject ADODB.Connection>", line 3, in Open
File "D:\Python33\lib\site-packages\win32com\client\dynamic.py", line 282, in _ApplyTypes_
result = self._oleobj_.InvokeTypes(*(dispid, LCID, wFlags, retType, argTypes) + args)
pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, 'ADODB.Connection', 'Provider cannot be found. It may not be properly installed.', 'C:\\Windows\\HELP\\ADO270.CHM', 1240655, -2146824582), None)
>>> path = os.getcwd()
>>> print(path)
D:\Python33