The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

import-bot (20211) [Avatar] Offline
#1
[Originally posted by jlt]

HI: I'm a newbie and need some debug pointers.
Any Debug suggestions for DAO Error?
The database is not password protected! no security set

RE: Page 262
Reading from an existing Access 97 MDB file
USING IDLE
>>>from win32com.client.dynamic import Dispatch
>>> dbEngine = Dispatch('DAO.DBEngine')
>>> qst = "Select * From TestRefs"
>>> rst = db.OpenRecordSet(qst)
>>> rst = db.OpenRecordSet(qst)
Traceback (innermost last):
File "<pyshell#6>", line 1, in ?
rst = db.OpenRecordSet(qst)
File "Dsmilieml_pythonPythonwin32comclientdynamic.py", line 394, in
__getattr__
raise pythoncom.com_error, details
com_error: (-2146825037, 'OLE error 0x800a0cb3', (0, 'DAO.Database',
'Operation is not supported for this type of object.', 'MSJETERR.HLP',
5003251, -2146825037), None)
==================
This code from a second test.mdb works

Function opentest()
Dim db As Database
Dim rst As Recordset
Dim st As String

Set db = OpenDatabase("c:psicpsic.mdb")
Set rst = db.OpenRecordset("Select * From testrefs")

Do While Not rst.EOF
st = st & rst![FirstName] & ", "
rst.MoveNext
Loop
MsgBox st

End Function
import-bot (20211) [Avatar] Offline
#2
Re: Access 97, fetch data
[Originally posted by jlt]

P.S. I my haste to paste into the message, noted that a line
"db = dbEngine.OpenDatabase('c:psic est.mdb')" was missing
Also note that the spindoczine.com drops (one Backslash)

Python 1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)] on win32
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> from win32com.client.dynamic import Dispatch
>>> dbEngine = Dispatch('DAO.DBEngine')
>>> db = dbEngine.OpenDatabase('c:psic est.mdb')
>>> qst = "Select * From TestRefs"
>>> rst = db.OpenRecordSet(qst)
Traceback (innermost last):
File "<pyshell#4>", line 1, in ?
rst = db.OpenRecordSet(qst)
File "Dsmilieml_pythonPythonwin32comclientdynamic.py", line 394, in
__getattr__
raise pythoncom.com_error, details
com_error: (-2146825037, 'OLE error 0x800a0cb3', (0, 'DAO.Database',
'Operation is not supported for this type of object.', 'MSJETERR.HLP',
5003251, -2146825037), None)
>>>
import-bot (20211) [Avatar] Offline
#3
Re: Access 97, fetch data
[Originally posted by jlt]

Eureka!
Found that Case is important in Python Windows (Sometimes!)
OpenRecordSet <> OpenRecordset
Now, Ain't That Something?

> P.S. I my haste to paste into the message, noted that a line
> "db = dbEngine.OpenDatabase('c:psic est.mdb')" was missing
> Also note that the spindoczine.com drops (one Backslash)
>
> Python 1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)] on win32
> Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
> >>> from win32com.client.dynamic import Dispatch
> >>> dbEngine = Dispatch('DAO.DBEngine')
> >>> db = dbEngine.OpenDatabase('c:psic est.mdb')
> >>> qst = "Select * From TestRefs"
> >>> rst = db.OpenRecordSet(qst)
> Traceback (innermost last):
> File "<pyshell#4>", line 1, in ?
> rst = db.OpenRecordSet(qst)
> File "Dsmilieml_pythonPythonwin32comclientdynamic.py", line 394, in
> __getattr__
> raise pythoncom.com_error, details
> com_error: (-2146825037, 'OLE error 0x800a0cb3', (0, 'DAO.Database',
> 'Operation is not supported for this type of object.', 'MSJETERR.HLP',
> 5003251, -2146825037), None)
> >>>
import-bot (20211) [Avatar] Offline
#4
Re: Access 97, fetch data
[Originally posted by daryl harms]

Hi John,

Sorry I didn't get back to you but glad you found your problem.
> Eureka!
> Found that Case is important in Python Windows (Sometimes!)
> OpenRecordSet <> OpenRecordset
> Now, Ain't That Something?
>
Yes, in general Python is case sensitive. This applies to variable and module
names. The exception on Windows is for path/file names in which case does not
matter.

One suggestion, I can give on your question regarding debugging (since you are
using IDLE) is when you run into an exception that you can recreate, toggle on
the "Auto open stack viewer" option on the debug window of the IDLE Python
Shell and then rerun what caused the exception. This time when the exception
occurs a stack trace window will popup. With it you can browse through to see
what all the local and global variables were set for each of the functions in
the call stack at the time the problem occurs and/or click to the offending
point(s) in the code along this stack. With this you often can quickly find
your problem. Although, in your situation here I don't know if it would have
helped.

(Note that if you are using the default version of IDLE that comes with Python
1.5.2 you might want to upgrade to IDLE 0.5 which can be found at
http://www.python.org/idle/ as it provides cleaner and easier to use version
of this function)

> > P.S. I my haste to paste into the message, noted that a line
> > "db = dbEngine.OpenDatabase('c:psic est.mdb')" was missing
> > Also note that the spindoczine.com drops (one Backslash)
Yes, the posting software drops \'s which is quite annoying. As you've found,
one has to escape them (i.e. enter two backslashes for each one you want
displayed).

> >
> > Python 1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)] on win32
> > Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
> > >>> from win32com.client.dynamic import Dispatch
> > >>> dbEngine = Dispatch('DAO.DBEngine')
> > >>> db = dbEngine.OpenDatabase('c:psic est.mdb')
> > >>> qst = "Select * From TestRefs"
> > >>> rst = db.OpenRecordSet(qst)
> > Traceback (innermost last):
> > File "<pyshell#4>", line 1, in ?
> > rst = db.OpenRecordSet(qst)
> > File "Dsmilieml_pythonPythonwin32comclientdynamic.py", line 394, in
> > __getattr__
> > raise pythoncom.com_error, details
> > com_error: (-2146825037, 'OLE error 0x800a0cb3', (0, 'DAO.Database',
> > 'Operation is not supported for this type of object.', 'MSJETERR.HLP',
> > 5003251, -2146825037), None)
> > >>>