win32com sql update problem

Tim Roberts timr at probo.com
Thu May 13 00:04:25 EDT 2010


Mark Carter <alt.mcarter at googlemail.com> wrote:
>
>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'")

Well, that's not the EXACT code, because that's clearly not line 64 in the
script above.  Do you actually have the file path hardcoded, as in your
example?  Or are you building it up from strings?

Does the net share exist at the time you run this?

You might print conn.ConnectionString just before the Execute.
-- 
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.



More information about the Python-list mailing list