Type mismatch: 'UBound'

OK, I know little to nothing about ASP coding, but I'm tasked with providing back-end support for an ASP based application.

Problem is, we're getting the following error:

Microsoft VBScript runtime  error '800a000d'

Type mismatch: 'UBound'

/admin/divisions/testtsg/xmloffers/generate_XMLOffers.asp, line 25



The generate_XMLOffers.asp coding looks as follows:

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>

<!--#INCLUDE virtual="/admin/divisions/includes/dataSyphon.asp" -->
<!--#INCLUDE VIRTUAL="/admin/divisions/testtsg/xmloffers/config.asp" -->

<%
Dim objDatabase            'local object for the Database class
Dim arrFaresData            'array to store returned resultset
Dim sqlFares      'query to pass as the select statement

sqlFares = "SELECT DestFrom, DestTo, BookBy, TravelFrom, TravelTo, Price, Eligibility, CallToAction, Link, Airline, isBA, LogoSRC, Continent, Country, isTopOffer, TopOfferLink, FreeTextInfo FROM " & var_countryCode & "_xml_offerFares WHERE BookBy >= DATEADD(DAY, - 1, GETDATE()) AND ValidFrom <= DATEADD(DAY, 0, GETDATE()) AND isDisplayed = 1 ORDER BY Continent, Country, Price ASC"

Set objDatabase = New Database
arrFaresData = objDatabase.GetArray(sqlFares)
Set objDatabase = Nothing

var_xml = "<?xml version=" & chr("34") & "1.0" & chr("34") & " standalone=" & chr("34") & "yes" & chr("34") & "?>" & vbcrlf
var_xml = var_xml & "<Offers>" & vbcrlf

currentContinent = ""
currentCountry = ""
c_index = 0
var_new = false

For i = 0 To UBound(arrFaresData, 2)
      ' Create the HTML      
      if arrFaresData(12,i) <> currentContinent then
            currentContinent = arrFaresData(12,i)
            if c_index <> 0 then
                  var_xml = var_xml & vbtab & vbtab & "</Country>" & vbcrlf
                  var_xml = var_xml & vbtab & "</Continent>" & vbcrlf
            end if
            var_xml = var_xml & vbtab & "<Continent>" & vbcrlf
            var_xml = var_xml & vbtab & vbtab & "<CID>" & arrFaresData(12,i) & "</CID>" & vbcrlf
            var_new = true
      end if
      
      if arrFaresData(13,i) <> currentCountry then
            currentCountry = arrFaresData(13,i)
            if c_index <> 0 then
                  if var_new <> true then
                        var_xml = var_xml & vbtab & vbtab & "</Country>" & vbcrlf
                  end if
            end if
            var_xml = var_xml & vbtab & vbtab & "<Country>" & vbcrlf
            var_xml = var_xml & vbtab & vbtab & vbtab & "<Name>" & arrFaresData(13,i) & "</Name>" & vbcrlf
            var_new = false
      end if
      
      if arrFaresData(6,i) = "S/Y" then
            var_eligibility = "Student/Youth"
      else
            var_eligibility = "Open to all"
      end if
      
      var_xml = var_xml & vbtab & vbtab & vbtab & "<Fare>" & vbcrlf
      var_xml = var_xml & vbtab & vbtab & vbtab & vbtab & "<DestFrom>" & replace(arrFaresData(0,i),"&","&amp;") & "</DestFrom>" & vbcrlf
      var_xml = var_xml & vbtab & vbtab & vbtab & vbtab & "<DestTo>" & replace(arrFaresData(1,i),"&","&amp;") & "</DestTo>" & vbcrlf
      var_xml = var_xml & vbtab & vbtab & vbtab & vbtab & "<BookBy>" & arrFaresData(2,i) & "</BookBy>" & vbcrlf
      var_xml = var_xml & vbtab & vbtab & vbtab & vbtab & "<TravelFrom>" & formatDateTime(arrFaresData(3,i), vbShortDate) & "</TravelFrom>" & vbcrlf
      var_xml = var_xml & vbtab & vbtab & vbtab & vbtab & "<TravelTo>" & formatDateTime(arrFaresData(4,i), vbShortDate) & "</TravelTo>" & vbcrlf
      var_xml = var_xml & vbtab & vbtab & vbtab & vbtab & "<Price>" & arrFaresData(5,i) & "</Price>" & vbcrlf
      var_xml = var_xml & vbtab & vbtab & vbtab & vbtab & "<Eligibility>" & var_eligibility & "</Eligibility>" & vbcrlf
      var_xml = var_xml & vbtab & vbtab & vbtab & vbtab & "<CallToAction>" & arrFaresData(7,i) & "</CallToAction>" & vbcrlf
      var_xml = var_xml & vbtab & vbtab & vbtab & vbtab & "<Link>" & replace(arrFaresData(8,i),"&","&amp;") & "</Link>" & vbcrlf
      var_xml = var_xml & vbtab & vbtab & vbtab & vbtab & "<Airline>" & arrFaresData(9,i) & "</Airline>" & vbcrlf
      var_xml = var_xml & vbtab & vbtab & vbtab & vbtab & "<LogoSRC>" & arrFaresData(10,i) & "</LogoSRC>" & vbcrlf
      var_xml = var_xml & vbtab & vbtab & vbtab & vbtab & "<freetext>" & arrFaresData(16,i) & "</freetext>" & vbcrlf
      var_xml = var_xml & vbtab & vbtab & vbtab & vbtab & "<topoffer>" & arrFaresData(14,i) & "</topoffer>" & vbcrlf
      var_xml = var_xml & vbtab & vbtab & vbtab & vbtab & "<topofferlink>" & arrFaresData(15,i) & "</topofferlink>" & vbcrlf
      var_xml = var_xml & vbtab & vbtab & vbtab & vbtab & "<creationdate>" & now() & "</creationdate>" & vbcrlf
      var_xml = var_xml & vbtab & vbtab & vbtab & "</Fare>" & vbcrlf
      
      c_index = c_index + 1
            
Next

var_xml = var_xml & vbtab & vbtab & "</Country>" & vbcrlf
var_xml = var_xml & vbtab & "</Continent>" & vbcrlf
var_xml = var_xml & "</Offers>" & vbcrlf

dim fs, f, path
set fs = Server.CreateObject("Scripting.FileSystemObject")
path = Server.MapPath("/admin/divisions/" & var_countryCode & "/xmloffers/xml")
set f = fs.CreateTextFile(path & "/xmloffers.xml" ,true)
f.write(var_xml)
f.close
set f=nothing
set fs=nothing

response.Redirect("admin.asp")
%>


I've tried sorting it out, mostly by means of throwing air-punches, no luck :)

What basically needs to happen is that an xml file needs to be generated on the Webserver itself by whichever user is configured. I've assigned full permissions on the physical folder itself as well as assigning write permissions within IIS, no go either.

I'm close to pulling my hair out of my head with this one, so please, any help will be greatly appreciated.


Thanks in advance!
LVL 3
dcsbeemerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Carl TawnSystems and Integration DeveloperCommented:
It sounds like the line:

    objDatabase.GetArray(sqlFares)

May not be returning an array. For debug purposes, right before the line:

    For i = 0 To UBound(arrFaresData, 2)

Add:

    If Not IsArray(arrFaresData) Then
        Response.Write "No array returned": Response.End
    End If
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
dcsbeemerAuthor Commented:
Hi carl_tawn, thanks for the reply, followed your advice and got the following:


No array returned


Not sure where to go from here though...
0
Carl TawnSystems and Integration DeveloperCommented:
Well, that means that, for whatever reason, the call to:

    objDatabase.GetArray(sqlFares)

Is not returning anything. That could mean there is a problem with it, or that the query it is running simply has no results. In the latter case you can guard against that problem by changing your For loop to:

    If IsArray(arrFaresData, 2) Then
        For i = 0 To UBound(arrFaresData, 2)
         ' Create the HTML    
         if arrFaresData(12,i) <> currentContinent then
              currentContinent = arrFaresData(12,i)
              if c_index <> 0 then
                   var_xml = var_xml & vbtab & vbtab & "</Country>" & vbcrlf
                   var_xml = var_xml & vbtab & "</Continent>" & vbcrlf
              end if
              var_xml = var_xml & vbtab & "<Continent>" & vbcrlf
              var_xml = var_xml & vbtab & vbtab & "<CID>" & arrFaresData(12,i) & "</CID>" & vbcrlf
              var_new = true
         end if
     
         if arrFaresData(13,i) <> currentCountry then
              currentCountry = arrFaresData(13,i)
              if c_index <> 0 then
                   if var_new <> true then
                        var_xml = var_xml & vbtab & vbtab & "</Country>" & vbcrlf
                   end if
              end if
              var_xml = var_xml & vbtab & vbtab & "<Country>" & vbcrlf
              var_xml = var_xml & vbtab & vbtab & vbtab & "<Name>" & arrFaresData(13,i) & "</Name>" & vbcrlf
              var_new = false
         end if
     
         if arrFaresData(6,i) = "S/Y" then
              var_eligibility = "Student/Youth"
         else
              var_eligibility = "Open to all"
         end if
     
         var_xml = var_xml & vbtab & vbtab & vbtab & "<Fare>" & vbcrlf
         var_xml = var_xml & vbtab & vbtab & vbtab & vbtab & "<DestFrom>" & replace(arrFaresData(0,i),"&","&amp;") & "</DestFrom>" & vbcrlf
         var_xml = var_xml & vbtab & vbtab & vbtab & vbtab & "<DestTo>" & replace(arrFaresData(1,i),"&","&amp;") & "</DestTo>" & vbcrlf
         var_xml = var_xml & vbtab & vbtab & vbtab & vbtab & "<BookBy>" & arrFaresData(2,i) & "</BookBy>" & vbcrlf
         var_xml = var_xml & vbtab & vbtab & vbtab & vbtab & "<TravelFrom>" & formatDateTime(arrFaresData(3,i), vbShortDate) & "</TravelFrom>" & vbcrlf
         var_xml = var_xml & vbtab & vbtab & vbtab & vbtab & "<TravelTo>" & formatDateTime(arrFaresData(4,i), vbShortDate) & "</TravelTo>" & vbcrlf
         var_xml = var_xml & vbtab & vbtab & vbtab & vbtab & "<Price>" & arrFaresData(5,i) & "</Price>" & vbcrlf
         var_xml = var_xml & vbtab & vbtab & vbtab & vbtab & "<Eligibility>" & var_eligibility & "</Eligibility>" & vbcrlf
         var_xml = var_xml & vbtab & vbtab & vbtab & vbtab & "<CallToAction>" & arrFaresData(7,i) & "</CallToAction>" & vbcrlf
         var_xml = var_xml & vbtab & vbtab & vbtab & vbtab & "<Link>" & replace(arrFaresData(8,i),"&","&amp;") & "</Link>" & vbcrlf
         var_xml = var_xml & vbtab & vbtab & vbtab & vbtab & "<Airline>" & arrFaresData(9,i) & "</Airline>" & vbcrlf
         var_xml = var_xml & vbtab & vbtab & vbtab & vbtab & "<LogoSRC>" & arrFaresData(10,i) & "</LogoSRC>" & vbcrlf
         var_xml = var_xml & vbtab & vbtab & vbtab & vbtab & "<freetext>" & arrFaresData(16,i) & "</freetext>" & vbcrlf
         var_xml = var_xml & vbtab & vbtab & vbtab & vbtab & "<topoffer>" & arrFaresData(14,i) & "</topoffer>" & vbcrlf
         var_xml = var_xml & vbtab & vbtab & vbtab & vbtab & "<topofferlink>" & arrFaresData(15,i) & "</topofferlink>" & vbcrlf
         var_xml = var_xml & vbtab & vbtab & vbtab & vbtab & "<creationdate>" & now() & "</creationdate>" & vbcrlf
         var_xml = var_xml & vbtab & vbtab & vbtab & "</Fare>" & vbcrlf
     
         c_index = c_index + 1
         
       Next
    Else
        '// Code to handle no results
    End If


This will prevent the error, but I would advise you run the query directly against your database to verify if any records should be returned or not, otherwise you will only be guarding against the side-effect of the problem rather than the root cause.
0
dcsbeemerAuthor Commented:
Hi carl_tawn


Thanks for the help so far, appreciate it.

You helped me figure out the problem, ran that select statement directly of the DB and ...it returned zip!
After some haggling we figured out that the Bookby value has to be NEWER than today's date, and the ValidFrom value has to be OLDER than today's date...

Created a new row with the correct values and it's working like a charm now!

Thanks for your help carl_tawn, 500 points to you sir!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP

From novice to tech pro — start learning today.