Solved

Type mismatch: 'UBound'

Posted on 2006-11-01
4
1,044 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

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…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

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