Solved

Type mismatch: 'UBound'

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

744 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now