Problem : using ADO in ASP

Steve Holden sholden at bellatlantic.net
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")
db.Open("Billing")
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("<p>")
	Response.Write( rs( "name" ) )
	rs.MoveNext()
Loop
db.Close
</SCRIPT>
<HR>
<SCRIPT Language="Python" RUNAT=Server>
db = Server.CreateObject("ADODB.Connection")
db.Open("Billing")
rs = db.Execute("select * from project")
Response.Write(repr(rs))
#Response.Write( rs["name"])
#Response.Write( str(rs.Fields.Count) )
db.Close
</SCRIPT>
</BODY></HTML>
-------------------------------------------------------
Results (of course the browser silently renders the
"<COMObject Execute>" as the null string...):
-------------------------------------------------------
3<p>WebCallback<p>TeamFinancial<p>USSInet
<HR>

</BODY></HTML>


(<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?

regards
 Steve



More information about the Python-list mailing list