What is this sub doing?

Results 1 to 2 of 2

Thread: What is this sub doing?

  1. #1
    Join Date
    Dec 1969

    Default What is this sub doing?

    I would like to understand what this sub is doing. Would someone with patience be so kind to give a step-by-step of this short subroutine?<BR><BR>Sub readItemsFromDatabase<BR> &#039;The path to your database:<BR> Dim db,q,rs,rsarr,menuID,mName,mLink,parent,cols,max<B R> <BR> db ="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("/data/menu.mdb")<BR> <BR> q = "SELECT menuID,mName,mLink,parent from tblMenu ORDER BY parent,menuID ASC"<BR> <BR> Set rs=Server.CreateObject("ADODB.Recordset")<BR> rs.CacheSize = 25 &#039; Cache data fetching<BR> rs.CursorType = 3<BR> rs.LockType = 3<BR> <BR> &#039;Opening database --- --<BR> rs.Open q,db<BR> <BR> &#039;Now using getRows because that&#039;s so sexy :}<BR> if NOT rs.EOF then<BR> rsarr = rs.GetRows()<BR> max = Ubound(rsarr,2)<BR> else <BR> max = 0<BR> end if<BR> &#039;Closing database, we don&#039;t need it anymore - we have the info in the array<BR> rs.close()<BR> Set rs = Nothing<BR> <BR> row=0<BR> do while(row&lt;=max) &#039;Looping rows<BR> &#039;Setting variables <BR> menuID = "m" & rsarr(0,row) &#060;-- what is this?<BR> mName = rsarr(1,row) &#060;-- what is this? etc??<BR> mLink = rsarr(2,row)<BR> if(mLink="null") then mLink="" <BR> parent = rsarr(3,row)<BR> if(parent&lt;&gt;0) then<BR> parent = "m" & parent<BR> else <BR> parent=""<BR> end if<BR> &#039;Making menu item<BR> Response.write("oCMenu.makeMenu(&#039;" & menuID & "&#039;,&#039;" &parent & "&#039;,&#039;" & mName & "&#039;,&#039;" & mLink & "&#039;)" & vbcrlf)<BR> row = row + 1<BR> loop<BR>End Sub

  2. #2
    Join Date
    Dec 1969

    Default RE: What is this sub doing?

    I assume you mean the lines you&#039;ve mrked?<BR><BR>getRows() returns a 2-dimensional array. these lines are simply using that array.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts