SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Thread: Looping

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Nov 2011
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Looping

    Hi to whom can help me

    I seem to get this error:

    Microsoft VBScript compilation error '800a040e'

    'loop' without 'do'

    /wspintranet/InformationTechnology/IT_Help_Desk_New/HelpDesk_AssetManagement/AssetManagement_Functions/Asset_Functions.asp, line 5155

    Loop
    ^


    Here is my code:

    function ListSoftwareLicenses()

    Dim strBody
    Dim i

    Set objBranchDC = Server.CreateObject("ADODB.Connection")
    objBranchDC.Open Application("StaffDetails_ConnectionString")
    Set objBranchRS = objBranchDC.Execute("SELECT Branches.BranchID, Branches.StrCity FROM Branches WHERE (((Branches.StrCity) Is Not Null)) ORDER BY Branches.StrCity;")
    do until objBranchRS.eof
    strCity=objBranchRS("StrCity")
    intBranchID=objBranchRS("BranchID")

    strBody = strBody & "<tr>"
    strBody = strBody & "<td class=""header_background"" colspan=""9"">Branch : "
    strBody = strBody & objBranchRS("StrCity")&"</td></tr>"

    i=2

    Set objDivisionDC = Server.CreateObject("ADODB.Connection")
    objDivisionDC.Open Application("StaffDetails_ConnectionString")
    Set objDivisionRS = objDivisionDC.Execute("SELECT BranchAddresses.OfficeName, BranchAddresses.StrCity FROM BranchAddresses WHERE (((BranchAddresses.StrCity)=" & intBranchID & ")) ORDER BY BranchAddresses.OfficeName;")

    do until objDivisionRS.eof
    strOfficeName=GetOfficeName(objDivisionRS("OfficeName"))

    strBody = strBody & "<tr><td class=""headline"" colspan=""9"">Company : " & strOfficeName &"<br>"

    Set objSoftwareDC = Server.CreateObject("ADODB.Connection")
    objSoftwareDC.Open Application("SoftwarePackages_ConnectionString")
    Set objSoftwareRS = objSoftwareDC.Execute("SELECT SoftwarePackages.SoftwareType, SoftwareVersions.Version, Count(SoftwareInstalled.MySoftwareID) AS CountOfSoftwareID FROM (SoftwarePackages RIGHT JOIN SoftwareInstalled ON SoftwarePackages.SoftwareID = SoftwareInstalled.SoftwareTypes) LEFT JOIN SoftwareVersions ON SoftwareInstalled.Versions = SoftwareVersions.VersionID GROUP BY SoftwarePackages.SoftwareType, SoftwareVersions.Version ;")

    do until objSoftwareRS.eof
    strSoftwareType=objSoftwareRS("SoftwareType")

    strBody = strBody & "<tr><td class=""headline"" colspan=""9"">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Software Package : " & strSoftwareType &"<br>"

    objSoftwareRS.movenext
    loop

    Set CountSerialNumbersDC= Server.CreateObject("ADODB.Connection")
    CountSerialNumbersDC.Open Application("SoftwarePackages_ConnectionString")
    Set CountSerialNumbersRS= CountSerialNumbersDC.Execute("SELECT Count(Purchasing.ID) AS CountOfID FROM Purchasing WHERE (((Purchasing.Company)=" & objDivisionRS("OfficeName") & ") AND ((Purchasing.Branch)=" & intBranchID & "));")

    strBody = strBody & "<tr><td class=""KnowledgeTable"" colspan=""9""> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; No. of Licenses Purchased by Company : " & CountSerialNumbersRS("CountOfID") &" &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; No. of Licenses Purchased by Group : <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Total Number of Licenses Installed for Company : &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Total Number of Licenses Installed for Group : </td></tr>"



    strBody=strBody & "<tr class=""tableHead""><td>Staff Member</td><td>Version</td><td>Date Installed</td></tr>"

    if CountSerialNumbersRS("CountOfID")= 0 then
    strBody=strBody & "<tr><td class=""text"" colspan=""9"" align=""center""><br>No Software Packages have been allocated for this Division/Branch</td></tr>"
    strBody=strBody & "<tr><td class=""text"" colspan=""9"" align=""center"">&nbsp;</td></tr>"

    else

    Set SerialNumbersDC= Server.CreateObject("ADODB.Connection")
    SerialNumbersDC.Open Application("SoftwarePackages_ConnectionString")
    Set SerialNumbersRS= SerialNumbersDC.Execute("SELECT SoftwarePackages.SoftwareType FROM SoftwarePackages ;")

    Do until SerialNumbersRS.eof
    strSoftwareType=SerialNumbersRS("SoftwareType")

    Set SerialNumbersDC= Server.CreateObject("ADODB.Connection")
    SerialNumbersDC.Open Application("SoftwarePackages_ConnectionString")
    Set SerialNumbersRS= SerialNumbersDC.Execute("SELECT SoftwareVersions.Version FROM SoftwareVersions WHERE (((SoftwareVersions.VersionID)=" & intSoftwareID & ")) ;")

    if not SerialNumbersRS.eof then
    i=2
    do while not SerialNumbersRS.eof
    strBody = strBody & "<tr class=""" & SetRowStyleGray(i) & """>"
    strBody = strBody & "<td class=""text"" valign=""top"">" & SerialNumbersRS("PostedByUserID") & "</td>"
    strBody = strBody & "<td class=""text"" valign=""top"">" & SerialNumbersRS("Version") & "</td>"
    strBody = strBody & "<td class=""text"" valign=""top"">" & SerialNumbersRS("DateOrder") & "</td>"

    i=i+1


    SerialNumbersRS.movenext
    Loop

    SerialNumbersRS.movenext
    Loop


    wend
    strBody = strBody & "<tr><td colspan=""9""><hr></td></tr>"
    end if
    end if


    objDivisionRS.movenext
    loop

    objBranchRS.movenext
    loop



    objBranchRS.Close
    Set objBranchRS = Nothing
    objBranchDC.Close
    Set objBranchDC = Nothing


    ListSoftwareLicenses= strBody
    end function


    i have put the line where the error is in bold.

    i would appreciate anyone who knows about my error.

  2. #2
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    Location
    Scotland
    Posts
    3,631
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Every Do should have a corresponding Loop. On the face of things you do - the problem is you are reusing recordset names (e.g. SerialNumbersRS) so the loops are getting confused. If you really must use nested loops (and you probably do NOT need to if you setup your database and structure your SQL query right) then use different recordset names for each loop.
    Ian Anderson
    www.siteguru.co.uk

  3. #3
    SitePoint Member
    Join Date
    Nov 2011
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    its still giving me the same error.. i changed the names

  4. #4
    SitePoint Zealot gidday's Avatar
    Join Date
    Jan 2007
    Posts
    191
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi bianx_07
    After a cursory look at your code a couple of things that jump out. You seem to have mixed looping types (If, While, Do). You have loops that end outside other loops. Where is the while for the wend. There are a heap of problems in the code.

    'loop' without 'do' is the best clue you could have possibly been given. Do yourself a favour and bust the function into separate pieces and then test them independently. You need to get the recordset and looping nesting under control.
    Joe
    "All that is necessary for the triumph of evil
    is that good men do nothing."


Bookmarks

Posting Permissions

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