Actually I'm not sure why but it appears they are creating a list and then
converting it to an array.  Try this.  If you for some reason you need both
the list and array, I'd do it like this

<cfset clientRegist = "">
<cfset eventIdArray = arrayNew()>

<cfqyery name="getStuff" datasource="">
  select * from eventAttendance where ClientId = '#client#'
</cfquery>

<cfloop query="getStuff">
  <cfset tmp = ListAPpend(clientReglist, eventId)>
  <cfset eventIdArray = ArrayAppend(eventIdArray, eventId)>
</cfloop>


<cfoutput>
  #clientRegList#<br />
  <cfdump var="#eventIdArray#">
</cfoutput>



-----Original Message-----
From: Adam Parker [mailto:[email protected]] 
Sent: Friday, February 20, 2009 10:33 AM
To: cf-newbie
Subject: Translate from Classic ASP to CF


Hello - 

I have posted this question on an ASP board to no avail.  My question
regards translating classic asp code to coldfusion 8.  My problem is I don't
completely understand the asp code in order to create the CF code.  I am
hoping the community can help me out as always.

This is the classic asp code:

/////////////////////////////
clientPreReg=","
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.open Application("database")
Set rs = Server.CreateObject("ADODB.Recordset")
set rs.ActiveConnection = conn
strQ = "SELECT * "
strQ = strQ & "FROM eventAttendance "
strQ = strQ & "WHERE clientID =" & client & ""
rs.Open strQ
if rs.eof then
        clientPreReg=","
else
        do while not rs.eof
                clientPreReg=clientPreReg & rs("eventID") & ","
                rs.moveNext
        loop
        clientPreRegCount=Len(clientPreReg)
        clientPreReg=Mid(clientPreReg, 2, clientPreRegCount-2)
        clientPreRegArray=split(clientPreReg,",")
end if
rs.close
///////////////////

What I think is going on is:

  Set a variable called "clientPreReg"
      clientPreReg=","

  Create a database connection, select all records from eventAttendance
where clientID equals the variable "client."
      Set Conn = Server.CreateObject("ADODB.Connection")
      Conn.open Application("database")
      Set rs = Server.CreateObject("ADODB.Recordset")
      set rs.ActiveConnection = conn
      strQ = "SELECT * "
      strQ = strQ & "FROM eventAttendance "
      strQ = strQ & "WHERE clientID =" & client & ""
      rs.Open strQ

  If I'm at the end of file, leave "clientPreReg" empty:
      if rs.eof then
        clientPreReg=","

  If I'm not at the end of file, append "clientPreReg" with eventID value
and another comma. Do this for all (rs.moveNext):
      else
        do while not rs.eof
                clientPreReg=clientPreReg & rs("eventID") & ","
                rs.moveNext

Loop through the "clientPreReg" array and removed commas:
      loop
        clientPreRegCount=Len(clientPreReg)
        clientPreReg=Mid(clientPreReg, 2, clientPreRegCount-2)
        clientPreRegArray=split(clientPreReg,",")

I need to understand what is going on before I can convert this into CF.  I
understand this isn't the place for ASP, but it has been a great help in the
past.

Thank you,
Adam 



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f

Archive: 
http://www.houseoffusion.com/groups/cf-newbie/message.cfm/messageid:4378
Subscription: http://www.houseoffusion.com/groups/cf-newbie/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.15

Reply via email to