We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you a podcast all about Citrix Workspace, moving to the cloud, and analytics & intelligence. Episode 2 coming soon!Listen Now

x

Type mismatch: 'UBound'

dcsbeemer
dcsbeemer asked
on
Medium Priority
1,080 Views
Last Modified: 2012-05-05
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!
Comment
Watch Question

Senior Systems and Integration Developer
CERTIFIED EXPERT
Commented:
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

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
CERTIFIED EXPERT

Author

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...
Carl TawnSenior Systems and Integration Developer
CERTIFIED EXPERT

Commented:
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.
CERTIFIED EXPERT

Author

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!
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.