Mailing List Archive

ADO example code failed:hlp!
This is a multi-part message in MIME format.
--------------5EA537113243C8D2F8AF2621
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Running Christian's code, I get following error message. What am I doing
wrong? It's same code, but the constants do not contain adModeReadWrite.
Pls help!
Thanks much in Adv,

import win32com.client
db=win32com.client.Dispatch("ADODB.Connection")
from win32com.client import constants
db.Mode = constants.adModeReadWrite
db.Open("Access DB")
db.Execute("create table mist (name varchar, wert long)")
rs=win32com.client.Dispatch("ADODB.Recordset")
rs.Open("mist", db, constants.adOpenDynamic, -1, constants.adCmdTable )
rs.AddNew()
rs.Fields("name").Value="hugo"
rs.Fields("wert").Value=123.45
rs.Update()

Python 1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)] on win32
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> ## working on region in file c:\tmp\python-aDA-KJ...
Traceback (innermost last):
File "<stdin>", line 1, in ?
File "c:\tmp\python-aDA-KJ", line 4, in ?
db.Mode = constants.adModeReadWrite
File "C:\Python\win32com\client\__init__.py", line 72, in __getattr__
raise AttributeError, a
AttributeError: adModeReadWrite
>>>
--
*****************************************************************************
S. Hoon Yoon (Quant) Merrill Lynch Equity Trading,
yelled@yahoo.com hoon@bigfoot.com(w)
"Miracle is always only few standard deviations away, but so is
catastrophe."
* Expressed opinions are often my own, but NOT my employer's.
"I feel like a fugitive from the law of averages." Mauldin
*****************************************************************************
--------------5EA537113243C8D2F8AF2621
Content-Type: text/x-vcard; charset=us-ascii; name="vcard.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Hoon Yoon
Content-Disposition: attachment; filename="vcard.vcf"

begin: vcard
fn: Hoon Yoon
n: ;Hoon Yoon
email;internet: hyoon@bigfoot.com
x-mozilla-cpt: ;0
x-mozilla-html: FALSE
version: 2.1
end: vcard


--------------5EA537113243C8D2F8AF2621--
ADO example code failed:hlp! [ In reply to ]
Hoon Yoon wrote in message <37A9F366.EA01D915@bigfoot.com>...
>Running Christian's code, I get following error message. What am I doing
>wrong? It's same code, but the constants do not contain adModeReadWrite.
>Pls help!
>Thanks much in Adv,

Most likely you have not run "makepy" over the ADO library.

Try:

>import win32com.client
>db=win32com.client.Dispatch("ADODB.Connection")

print db

If it says "COM object <ADODB.Connection>", you have not used makepy. If it
says "win32com.gen_py.blah..." then it is a different problem.

To run makepy, select it from the Pythonwin tools menu, or double-click on
"Python\win32com\client\makepy.py"

Mark.
ADO example code failed:hlp! [ In reply to ]
> From: Hoon Yoon [mailto:hyoon@bigfoot.com]
>
>
> Running Christian's code, I get following error message. What
> am I doing
> wrong? It's same code, but the constants do not contain
> adModeReadWrite.
> Pls help!
> Thanks much in Adv,
>
> import win32com.client
> db=win32com.client.Dispatch("ADODB.Connection")
> from win32com.client import constants

In order to access these constants you need to do the following:

adolib = win32com.client.gencache.EnsureModule(
'{00000200-0000-0010-8000-00AA006D2EA4}', # TypeLib GUID for ADO
win32con.LANG_NEUTRAL, # LCID
2, # Major version #
1, # Minor version #
win32com.client.genpy.GeneratorProgress()) # Silent progress
indicator.
(The above assumes you have the latest MDAC installed, if you don't plesae
pick up the latest bits from

Then instead of using win32com.client.Dispatch(), you can now do the
following:
# Create ADO connection object
db = adolib.Connection()
# Create ADO recordset object
rs = adolib.Recordset()

Bill