Hello all.

We're using ActivePython 2 and MS IIS/ASP for web application development (I
know I know, we should be using apache... that's not an option for our
clients).

We ran into a weird result when using Python to talk via COM to the ADO
database object. This may be us being dense, or it may be a subtle bug...
here's the code:

------------
<%@ Language=Python %>
<html>
<body>

<%

OBJdbLog = Server.CreateObject("ADODB.Connection")
OBJdbLog.Open("test") #An ODBC datasource name

# now we are going to try to query said database
SQLQuery = "SELECT * from Artists;" # a valid query
DBRecord = OBJdbLog.Execute(SQLQuery) #Standard ADO syntax

DBRecord[0].MoveFirst()
FieldCount = DBRecord[0].Fields.Count
while not DBRecord[0].EOF:
        row = []
        for i in range(FieldCount):
            MyFieldValue = DBRecord[0].Fields(i).Value
            row.append(MyFieldValue)
        Response.write(str(row))
        DBRecord[0].MoveNext()  #move to next record

%>
</body>
</html>
------------

The weird part is in "DBRecord = OBJdbLog.Execute(SQLQuery)".

Experience (with other AXScript languages) dictates that this command should
return a  RecordSet object, so we were confused when we got a seemingly
non-descript tuple back instead.

After much confusion, scraping and digging, it turns out that this tuple is
composed of two elements: a COM object and "-1". For kicks, I poked at that
first member and discovered that it /was/ the recordset we need.

So the question is, "is this supposed to be wrapped in a tuple, why, and
what does -1 represent?" Is this some weird COM thing that is usually
isolated from the caller, but isn't in this case?

If this is a feature and not a bug, this is certainly an unexpected result
to running the com method (.Execute) and is different from VBScript and
JScript (and probably C and VB and anything else that uses ADO). It should
be documented in the AXScript docs. We wasted hours on this, and I expect
that many python coders will attempt to use ADO, and may waste similar
hours.

Of course, there is still the possibility that we're just confused; we're
pretty new to Python. If that's the case, can someone set us straight?

_______________________________________________
ActivePython mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/activepython

Reply via email to