win32com sql update problem

M

Mark Carter

Consider the following snippet of code:

import win32com.client

DSN = 'PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=M:\\Finance\\camel\
\camel.mdb;'
conn.Open(DSN)
cursor = conn.Execute("UPDATE tblInvoice SET InvComments='Python'
WHERE InvBillingPeriod = 'April 2010' AND InvJobCode = '2169'")
rows = cursor.Affected_Rows()
print rows
conn.Close()

I am using Python 2.6.5, and pywin32. If I try to run it, I get the
response:
Traceback (most recent call last):
File "C:/Users/mcarter/tacc/pypms/post.py", line 79, in <module>
AdjustPms(d)
File "C:/Users/mcarter/tacc/pypms/post.py", line 64, in AdjustPms
cursor = conn.Execute("UPDATE tblInvoice SET InvComments='Python'
WHERE InvBillingPeriod = 'April 2010' AND InvJobCode = '2169'")
File "<COMObject ADODB.Connection>", line 3, in Execute
File "C:\Python26\lib\site-packages\win32com\client\dynamic.py",
line 272, in _ApplyTypes_
result = self._oleobj_.InvokeTypes(*(dispid, LCID, wFlags,
retType, argTypes) + args)
pywintypes.com_error: (-2147352567, 'Exception occurred.', (0,
u'Microsoft JET Database Engine', u"Cannot open database ''. It may
not be a database that your application recognizes, or the file may be
corrupt.", None, 5003049, -2147467259), None)

I have used the same DNS to retrieve data from the database using
SELECT statements, so I'm at a loss to figure out what's going wrong.
It seems to think the database name as an empty string. I'm not sure
if that's the root cause of the problem, though. Any ideas?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,150
Members
46,697
Latest member
AugustNabo

Latest Threads

Top