[python-win32] MS Access query error
Phill Atwood
me at phillatwood.name
Mon Mar 13 22:47:09 CET 2006
I'm trying to get at some data in MS Access. This long query updates a
table. I'm wondering if this query is failing. Anyways, when I run
dbpath = os.getcwd() + "\\Test (2).mdb"
conn = win32com.client.Dispatch(r'ADODB.Connection')
DSN = 'PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=' + dbpath + ';'
conn.Open(DSN)
rs = win32com.client.Dispatch(r'ADODB.Recordset')
sqlstatement = 'UPDATE [Acute avian (liquids)] INNER JOIN
(([Label info] INNER JOIN [User selection] ON [Label info].Crop = [User
selection].[Select Crop]) INNER JOIN [Acute mammal (liquids)] ON [Label
info].[AI Code] = [Acute mammal (liquids)].[AI Code]) ON ([Acute avian
(liquids)].[AI Code] = [Acute mammal (liquids)].[AI Code]) AND ([Acute
avian (liquids)].Group = [Acute mammal (liquids)].Group) SET [Acute
avian (liquids)].[Application rate -kg per ha] = [Label info]![AI rate -
kg per ha], [Acute mammal (liquids)].[Application rate -kg per ha] =
[Label info]![AI rate - kg per ha] WHERE ((([Label info].[Application
detail])="Ground spray"));'
print sqlstatement
rs.Open(sqlstatement, conn)
print "rs.RecordCount = " + rs.RecordCount
I get the error
[snip...]
intypes.com_error: (-2147352567, 'Exception occurred.', (0,
'ADODB.Recordset', 'Operation is not allowed when the object is
closed.', 'C:\\WINDOWS\\HELP\\ADO270.CHM', 1240653, -2146824584), None)
on the very last statement.
I'm still new to this stuff and trying to get my head around it. I need
to be able to duplicate this
query which works fine by hand in Access. Any help is appreciated.
Thanks,
Phill
More information about the Python-win32
mailing list