[python-win32] help with ASP, COM and ODBC

Matt Agler Matt.Agler@frontstep.com
Fri, 18 Jan 2002 12:08:04 -0500


I'm working on a varient of this, where the SQL code returns closed result
sets.
	declare @x int
	set @x = 1
	select @x

I want to get the result set from line 3 but line 2 returns a closed record
set.  So I check the State attribute, and if it's closed, I move on to the
next RecordSet.  The problem is that the object returned from
NextRecordSet() doesn't know about the "State" attribute and so I get an
exception (the original recordSet from the Execute works fine).  In VB, this
works.  Any ideas?

rs, recs_affected = db.Execute('select a, b, from xyz')
try:
   while rs <> None and rs.State == 0: #skip closed recordSets (fails on
second rs)
      rs = rs.NextRecordSet()
   while rs <> None and not rs.EOF :
       print 'a =', rs.Fields.Item(0).Value
       rs.MoveNext()
except Exception, e:
   print e

Thanks in advance (hope this isn't a stupid question),

-Matt

--------------------------
from win32com.client import Dispatch

db = Dispatch('ADO.Connection')
db.Open('Provider=blah;blah;blah')

rs, recs_affected = db.Execute('select a, b, from xyz')

while not rs.EOF :
    print 'a = %s, b = %s' % (rs.Fields.Item(0).Value, 
rs.Fields.Item(1).Value)
    rs.MoveNext()

Mark Ainsworth wrote:

> I'm sorry if this has been asked before but there is so much info out  
> there I don't know where to start looking. 
> 
> I've successfully set up an ODBC with IIS2 and can open it and close  
> it from a python scripted ASP page. Now this may seem dumb , but are  
> there any simple tutorials as to nowhow to access and use this data .  
> I've got a record set, but how can I get the data out. ObjRS[x] comes  
> back with "enumeration not allowed" errors. I can do objRS(x) with VB  
> though ! 
> 
> If it's documented somewhere then please just point me to the document. 
> 
> Thanks. 
> 
> *Mark Ainsworth* 
> 
> *Quality Manager* 
> 
> Sundance Multiprocessor Technology Ltd. 
> 
> Chiltern House, Waterside, Chesham, Bucks HP5 1PS 
> 
> Tel. +44 1494 793167 Fax. +44 1494 793168 
> 
> MarkA@NO-SPAM.sundance.com http://www.sundance.com 
>