Solved

Type mismatch: 'UBound'

Posted on 2006-11-01
4
1,042 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!
0
Comment
Question by:dcsbeemer
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 500 total points
ID: 17849702
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
 
LVL 3

Author Comment

by:dcsbeemer
ID: 17849736
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
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 17849937
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
 
LVL 3

Author Comment

by:dcsbeemer
ID: 17850249
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

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Recordset containing single quotes 8 49
MS SQL and column defined as time 7 26
Record locking on classic ASP 3 40
ASP Error Handler 5 21
I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question