Problem : using ADO in ASP

Steve Holden sholden at
Thu Feb 3 14:48:55 CET 2000

Mark Hammond wrote:
>[question about using ADO]
> The traceback gives you a clue:
> > Output from Python :
> >
> >
> > Python ActiveX Scripting Engine error '80020009'
> >
> > Traceback (innermost last): File "<Script Block
> > >",
> >  line 7, in ? Response.Write( rs.Fields("name") )
> > AttributeError:
> >  'tuple' object has no attribute 'Fields'
> The problem is that for some reason, rs is a "tuple" object - I
> suggest adding a "print" statement (or more likely a
> "Response.Write("rs = " + repr(rs))"
> Note that if you add an "import win32traceutil" line anywhere, you can
> use the Pythonwin "tools" menu to start a collector that will pick up
> any print statements you may add...
> Mark.

A timely thread for me, as I am just struggling with
ASP Python, and having similar problems.  In particular,
could anyone point me to documentation on the way the
ASP structures can be accessed in Python?

I modified Toby's code slightly to allow me to access my
own database, and printed a little more output.  I also
followed Mark's suggestion of using repr() to see what
was being returned.

New code:
<% @LANGUAGE=Python %>
<SCRIPT Language="VBScript" RUNAT=Server>
set db = Server.CreateObject("ADODB.Connection")
set rs = Server.CreateObject("ADODB.RecordSet")
set rs = db.Execute("select * from project")
Response.Write( rs.Fields.Count )
Do While Not rs.EOF
	Response.Write( rs( "name" ) )
<SCRIPT Language="Python" RUNAT=Server>
db = Server.CreateObject("ADODB.Connection")
rs = db.Execute("select * from project")
#Response.Write( rs["name"])
#Response.Write( str(rs.Fields.Count) )
Results (of course the browser silently renders the
"<COMObject Execute>" as the null string...):


(<COMObject Execute>, -1)
Clearly there's some clever stuff hidden under the COM
object which I don't understand.  Without wishing to go
through the "six months of mental fog" which I've read
can be necessary to understand COM, can anyone point me
to a simple morphology of ADO in Python?


More information about the Python-list mailing list