> I'm looking at some vbs code and want to convert it to CF. I 
> have most of it, however, am not quite sure about one spot. 
> They use the line of code:
> 
> Set orr=DBConnect.Execute(strSQL)
> DBConnect had been set to Creat connection to DB
> strSQL is the name of the query that they wrote.
> 
> That makes sense to me. But then they set data fields and 
> then to move to the next record they use orr.MoveNext
> I'm wondering if there is an equivalent in CF. I thought a 
> loop query would do the trick but I'm not getting the results 
> that I need.

There is no direct analog to this in CF, because querying databases and
looping over recordsets is handled instead using CFQUERY and CFOUTPUT, which
is a bit simpler than the way you'd do it with ADO in ASP. CF, unlike VBS in
ASP, doesn't provide objects with methods (such as the Recordset object with
its MoveNext method).

If you wanted to build something as similar in CF to your VBS/ASP code, you
could use a loop within a CFSCRIPT block, although that wouldn't be an exact
analog either:

<cfquery name="qFoo" ...>
        SELECT field1, field2 ...
</cfquery>

<table>
<cfscript>
for (i = 1; i lte qFoo.RecordCount; i = i + 1) {
        WriteOutput("<tr>");
        WriteOutput("<td>" & qFoo.field1[i] & "</td>");
        WriteOutput("<td>" & qFoo.field2[i] & "</td>");
        WriteOutput("</tr>");
}
</cfscript>
</table>

Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/
voice: (202) 797-5496
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Get the mailserver that powers this list at http://www.coolfusion.com
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to