[python-win32] Re: Recovering from AODB Exceptions, possible?
Roger Upole
rwupole at msn.com
Sat Feb 10 05:41:50 CET 2007
Rex Corrovan wrote:
> So I have a function that ries to add a record:
>
> def EntryAdd(self, dataDict):
> try:
> self._DBConn.MoveFirst()
> self._DBConn.AddNew()
> for key, value in dataDict.items():
> self._DBConn.Fields.Item(key).Value = value
> self._DBConn.Update()
> except pywintypes.com_error, e:
> print e
> print 'error text here'
> return True
>
> So if the error already exists I get an exception, no problem, I handle and
> log it.
>
> The problem here is that anything I now try to use this recordset for will
> throw an exception. Is there any way to recover from this without recreating
> the whole recordset?
It's kind of hard to tell without a traceback, but at a guess
it looks like the offending record created with AddNew is
never removed from the recordset after the error occurs.
CancelUpdate() should get rid of it.
hth
Roger
More information about the Python-win32
mailing list