[python-win32] Calling ADO/XML from Python

mokumgast38-pancakes at yahoo.com mokumgast38-pancakes at yahoo.com
Wed Dec 15 22:41:37 CET 2004


Currently I am testing a few samples in Python from:
Programming Microsoft® SQL Server™ 2000 with XML,
Second Edition 
(http://www.microsoft.com/mspress/books/6137.asp)
The following fragment (from chapter 6) does not work:

_conn =
GenericUtil.CreateCOMObject('ADODB._connection')
_conn._connectionString = "DATA
PROVIDER=SQLOLEDB;SERVER=%s;Database=%s;Persist
Security Info=False;User ID=%s;Password=%s"
_conn.Provider = 'SQLXMLOLEDB.3.0'
_conn.Open()
_cmd = GenericUtil.CreateCOMObject('ADODB.Command')
_cmd.Active_connection = _conn
_cmd.Dialect =
'{C8B522D7-5CF3-11CE-ADE5-00AA0044773D}'
_outstr =  GenericUtil.CreateCOMObject("ADODB.Stream")
_outstr.Open()
_cmd.Properties.Item('Output Stream').Value = _outstr
_cmd.CommandText = "select * from test for xml auto"
_cmd.Execute(Options = 1024)
_outstr.Position = 0
print _outstr.ReadText(-1)

Because COM is complaining about the output stream,
which is supposted to be set in:
_cmd.Properties.Item('Output Stream').Value = _outstr

The same code in vbs does work.

I am running winXP, ADO 2.8, python 2.3.4



More information about the Python-win32 mailing list