Object Required Error...

I am coming up with an Object Required Error on line 68....(I'll point out the line)

This happened all of a sudden.  The code was working, and then all of a sudden today I get this error  (even though I did nothing to the code...)

here's the code, and then how I use it:
<script language="javascript" runat="server">
function jssort(a)
{
   return (new VBArray(a)).toArray().sort().join(String.fromCharCode(0));
}
</script>
<%
class invcat
   dim id, category, parentid, description
end class
class invcats
   dim cats
   dim sortindex()
   sub class_initialize
        set cats = server.createobject("Scripting.Dictionary")
   end sub
   sub class_terminate
        set cats = nothing
   end sub
   sub BuildFromDB(connstr, tableName)
       LoadFromDB connstr, tableName
       SetLabels
       BuildSortIndex
   end sub
   sub BuildFromArray(array)
       LoadFromArray array
       SetLabels
       BuildSortIndex
   end sub
   sub LoadFromArray(a)
       dim i,n,line,cat
       for i = lbound(a) to ubound(a)
            line = split(a(i),"^")
            set cat = new invcat
            cat.id = line(0)
            cat.parentid = line(1)
            cat.category = line(2)
            cats.add cat.id, cat
       next
   end sub
      sub LoadFromDB(conn, tableName)
            dim rs, cat
            set rs = server.createobject("ADODB.Recordset")
                  rs.open "select gcID, parentID, gCat from " & tableName & "", conn
                        do while not rs.eof
                              set cat = new invcat
                              cat.id = rs("gcID")
                              cat.parentid = rs("parentID")
                              cat.category = rs("gCat")
                              cats.add clng(cat.id), cat
                              rs.movenext
                        loop
                  rs.close
            set rs = nothing
      end sub
   sub SetLabels
      dim i
      for each i in cats.keys
          cats(i).description = mid(BuildLabel(i),4)
      next
   end sub
   function BuildLabel(id)  
       if id = 0 then
          BuildLabel = ""
          exit function
       else
          dim curcat
          set curcat = cats(id)
          BuildLabel = BuildLabel(curcat.parentid) & " - " & curcat.category
       end if
   end function
   sub BuildSortIndex
       dim key,descripts,desc
       set descripts = server.createobject("Scripting.Dictionary")
       for each key in cats.keys
           desc = cats(key).description
           if descripts.exists(desc) then
              descripts(desc) = descripts(desc) & "|" & key
           else
              descripts(desc) = key
           end if
       next
       dim sorted
       sorted = split(jssort(descripts.keys), chr(0))
       dim i,n,keys,index
       index = 0
       redim sortindex(cats.count - 1)
       for i = lbound(sorted) to ubound(sorted)
           keys = split(descripts(sorted(i)), "|")
           for n = lbound(keys) to ubound(keys)
              sortindex(index) = keys(n)
              index = index + 1
           next
       next
   end sub
function SelectBoxWithSelection(selection)
        dim i,out,cat
        out = "<select name=""gcID"">" & vbcrlf
            if adminCheck() then
                  out = out & "<option value='0'>Root</option>"
            end if
        for i = lbound(sortindex) to ubound(sortindex)
           if cats.exists(clng(sortindex(i))) then
           set cat = cats(clng(sortindex(i)))
                     ll = ""
               if cint(cat.id) = cint(selection) then
                    ll=" selected"
               end if
                out = out & "<option value=""" & cat.id & """"&ll&">" & cat.description &"</option>" & vbcrlf
        end if
        next
        out = out & "</select>" & vbcrlf
        SelectBoxWithSelection = out
  end function
  function SelectBox
     SelectBox = SelectBoxWithSelection("")
  end function
end class
%>


how I use it:  (TheFile(2,0) = a numerical value from a 2d Array)
<%
dim myCats
set myCats = new invcats
      call myCats.BuildFromDB(inrsConn, "ModFilesCats")
      write(myCats.SelectBoxWithSelection(TheFile(2,0)))
set myCats = nothing
%>
LVL 25
kevp75Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
sonicysaConnect With a Mentor Commented:
one place that may be an issue:  gcID 28 refers to parentID 27 which does not exist
0
 
kevp75Author Commented:
i'm sorry, I forgot to point out line 68.

it's the line that reads:
set curcat = cats(id)

in the BuildLabel function
0
 
peh803Commented:
Generally, you use the "set" keyword when you're trying to create a reference to an object.

In this case, it seems that cats(id) is not an object, so it doesn't like it.  

try changing this:
   set curcat = cats(id)

to this:
   curcat = cats(id)

Regards,
Phil
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
peh803Commented:
Looking more at the code you've posted, I notice that you're treating "cats" as a collection, but you're not passing it in explicitly to the BuildLabel() function.  You may try passing that in to see if you have more luck with that.

Also, if you'll ever have a case where you may have an empty collection (i.e., no cat objects exist), then you may want to wrap that statement with an isObject() detection -- something like:

If isObject(cats(id)) then
   ... do your stuff ...
end if

HTH,
peh803
0
 
kevp75Author Commented:
it's odd.  It was working exactly how I posted last week, and then all of a sudden it doesn't?

it also works great as is on another site I developed
0
 
kevp75Author Commented:
damn tab....I will try that out though
0
 
kevp75Author Commented:
got rid of the set, and now I get "Object doesn't support this property or method"
0
 
peh803Commented:
okay, well based on the fact that you're referring to an object in a collection (or trying to, albeit unsuccessfully), it seems that the "set" should be in there.  Did you try the "isObject" check, and also passing the collection into the function explicitly?

Thanks,
Phil
0
 
sonicysaCommented:
How many iterations does it get through?

ie. if you put a response.write in the

function BuildLabel(id)  
       if id = 0 then
          BuildLabel = ""
          exit function
       else
          dim curcat
          '--I think this is correct for allowing you to let the error happen and then write out the current id that it's on..That will allow you to know which record in the dictionary object might be offending if that is what it is.
          on error resume next
          set curcat = cats(id)
          if error <> "" then
             response.write "id: " & id & "--"
             response.end
          end if
          on error goto 0
          BuildLabel = BuildLabel(curcat.parentid) & " - " & curcat.category
       end if
   end function

I would also declare the language you are using verses relying on the environment default since you have javascript declared at the top.
I have seen problems with this kind of thing on the browser side not the server side though.
0
 
kevp75Author Commented:
@sonicysa
I get id: 1--

which is odd, because that id shouldn't exist at the level I am at in this category scheme.  It should read 0

@phil
sorry for being dense, but I am not sure I quite know what you mean by:"and also passing the collection into the function explicitly"
0
 
kevp75Author Commented:
@phil, I did add in the if isObject, however i still get the same Object Required Error
0
 
kevp75Author Commented:
i apologize for being dense, but I am quite frustrated by this.

The same exact code, on the same exact server works on a one site, but not another.

Both sites have almost the same exact structure as well
0
 
kevp75Author Commented:
ok...i'm messing around a little....I'm wondering if I comment out the sub class_initialize/end sub lines and comment out sub class_terminate/end sub lines, and move set cats = nothing to the line above end class...

nope, that didnt work, that just gave me a syntax error on set cats = server.createobject...
0
 
sonicysaCommented:
vbscript as an interpretive language is kind of unpredictable at times.

Take a gander at this: http://www.4guysfromrolla.com/webtech/050201-1.shtml
 
Basically that page talks about how using set x = object is really coping the pointer/reference to the original object. So anything you do to curcat is being done to cats as well.

 
0
 
sonicysaCommented:
How about not trying to make a copy of the object and just use cats?

BuildLabel = BuildLabel(cats(id).parentid) & "-" & curcat.category

Was there a reason that you were trying to create a copy of the original?

0
 
sonicysaCommented:
I think we will still need to find out what data is in there on every loop. Like what data does work and does it ever make it through the first call to BuildLabel that is not 0 so add another response.write that is not inside the if statement and output both the parentid and the id

Maybe like this:

function BuildLabel(id)  
      response.write id & "<br>"
      if id = 0 then
          BuildLabel = ""
          exit function
       else
          dim curcat
          on error resume next
          set curcat = cats(id)
          if error <> "" then
             response.write "id: " & id & "--<br>"
             response.end
          end if
          on error goto 0
          BuildLabel = BuildLabel(curcat.parentid) & " - " & curcat.category
       end if
end function

I also wonder if the reference is getting lost through the recursive calls??
Like the first time you end up with a number other than 1 it makes it through but the second time it is in a recursive state and thus the object reference is a ref to a ref which is broken depending on the way the OS and hardware is. Like maybe on the server that it works on recursive calls do not do strange things across memory or multiple processors or something.. I don't know.. What are some of the differences between the two machines?

0
 
sonicysaCommented:
you could also try making cats a session variable and see if that helps the scoping. LOL that is kinda a pain and probably wouldn't be good code practice. But it would tell you something about the scoping if it worked.
0
 
sonicysaCommented:
remember how you get a object required as the code was. But, when you remove the set statement, you get the "Object doesn't support this property or method"

check via response.write whether the numbers change between when you have the set and don't have the set statement.

I am guessing that the second loop through you get your first message but the first loop through you actually have an object and setting curcat without the "set" statement throws the object requiered...

0
 
peh803Commented:
What I mean by "passing the collection into the function explicitly" is something more like this:

Instead of this (current state of the function):
  function BuildLabel(id)  
       if id = 0 then
          BuildLabel = ""
          exit function
       else
          dim curcat
          set curcat = cats(id)
          BuildLabel = BuildLabel(curcat.parentid) & " - " & curcat.category
       end if
   end function

Try passing in the cats collection explicitly as an argument, like this:
  function BuildLabel(id, cats)  
       if id = 0 then
          BuildLabel = ""
          exit function
       else
          dim curcat
          set curcat = cats(id)
          BuildLabel = BuildLabel(curcat.parentid) & " - " & curcat.category
       end if
   end function

Thanks,
Phil
0
 
peh803Commented:
Also, I see that you've got two routines that populate your collection -- one from an array, one from a database -- which is being used in this failing case?  

Thanks,
Phil
0
 
kevp75Author Commented:
the database
0
 
sonicysaCommented:
Kev, did you get a chance to try it changing it from  

dim curcat
          set curcat = cats(id)
          BuildLabel = BuildLabel(curcat.parentid) & " - " & curcat.category


to

'//dim curcat
'//          set curcat = cats(id)
   BuildLabel = BuildLabel(cats(id).parentid) & " - " & cats(id).category
0
 
kevp75Author Commented:
i did, i get the 'Object Required cats(...)' error on that line now....
0
 
kevp75Author Commented:
with:
function BuildLabel(id)  
      response.write id & "<br>"
      if id = 0 then
          BuildLabel = ""
          exit function
       else
          dim curcat
          on error resume next
          set curcat = cats(id)
          if error <> "" then
             response.write "id: " & id & "--<br>"
             response.end
          end if
          on error goto 0
          BuildLabel = BuildLabel(curcat.parentid) & " - " & curcat.category
       end if
end function


no matter what I am on I get:
1
id:1--

even though I (assume) I should get 5
0
 
sonicysaCommented:
did you try peh's suggestion of passing in the object?

you will need to modify it more because he did not change the other pieces of the code.

function BuildLabel(id, cats)  
       if id = 0 then
          BuildLabel = ""
          exit function
       else
          '//dim curcat
          '//set curcat = cats(id)
          '// he didn't set the curcat.parentid to the object
          '//BuildLabel = BuildLabel(curcat.parentid) & " - " & curcat.category
          BuildLabel = BuildLabel(cats(id).parentid, cats) & " - " & cats(id).category
       end if
   end function
0
 
sonicysaCommented:
what are the contents of the dictionary object? can you post the first 10 rows or something?
0
 
peh803Commented:
Are you always killing your object after you create it?  You might want to make sure you've always got some cleanup happening ... so when you're done, you do set x = nothing..

Also, what do you get if you write out:

cats.keys.count ?

Thanks,
Phil
0
 
kevp75Author Commented:
i did try his suggestion, however I got a 'Wrong Number of arguments' error on it

the records in the dict object are:
gcID     gCat       uID          PrivFolder           parentID
1      Documentation      3      0      0
2      Files      3      0      0
3      Software      3      0      0
5      Drivers      3      0      0
6      Templates      3      0      0
7      Browsers      3      0      3
8      Programming      3      0      3
9      Web Development      3      0      3
11      Scripts      3      1      0
14      ASP      3      0      11
15      Javascript      3      0      11
16      vbScript      3      0      11
17      XML      3      0      11
18      CSS      3      0      11
19      PHP      3      0      11
20      Projects      3      0      0
21      Vietnam Battlefield Tours      3      0      20
22      Global Solar Energy      3      0      20
23      JMB Financial Management      3      0      20
24      A Pen Lovers Paradise      3      0      20
25      SQL      3      0      11
26      Quotes      3      1      0
28      Open Office      3      0      27
29      Microsoft Office      3      0      27
30      ASP Components      3      0      3
0
 
sonicysaCommented:
sub class_terminate
        set cats = nothing
end sub

set myCats = nothing

I think both of these will tell you that he is closing the objects. It's right in the code that he posted Phil.
0
 
sonicysaCommented:
gcID     gCat       uID          PrivFolder           parentID
1     Documentation     3     0     0

so it will go through the loop once??
if parentID is zero here it will exit on the next loop correct?
0
 
kevp75Author Commented:
objects are cleaned up (as per the code I posted in the question)
0
 
sonicysaCommented:
nevermind, it does each i in cats
0
 
peh803Commented:
>>i did try his suggestion, however I got a 'Wrong Number of arguments' error on it

I think this is because my suggestion was only half of the fix -- it should be like this (fixed version of what I posted earlier):

   function BuildLabel(id, cats)  
       if id = 0 then
          BuildLabel = ""
          exit function
       else
          dim curcat
          set curcat = cats(id)
          BuildLabel = BuildLabel(curcat.parentid, cats) & " - " & curcat.category
       end if
   end function

This is also what sonicysa said previously.

Thanks,
Phil / peh803
0
 
kevp75Author Commented:
no.  It is supposed to display a drop-down list staring at the parent category (0) and iterating through where parentID = gcID

so say like this(ish):
Projects
Projects - Global Solar Energy
Projects - Vietnam Battlefield Tours
Projects - JMB Financial Management
Projects - A Pen Lovers Paradise

etc...

p.s...went through a bit more thoroughly, and did more cleanup...new cod ein next post  (note the only thing's added are some = nothing for cleanup on the sets)
0
 
kevp75Author Commented:
<script language="javascript" runat="server">
function jssort(a)
{
   return (new VBArray(a)).toArray().sort().join(String.fromCharCode(0));
}
</script>
<%
class invcat
   dim id, category, parentid, description
end class
class invcats
   dim cats
   dim sortindex()
   sub class_initialize
        set cats = server.createobject("Scripting.Dictionary")
   end sub
   sub class_terminate
        set cats = nothing
   end sub
   sub BuildFromDB(connstr, tableName)
       LoadFromDB connstr, tableName
       SetLabels
       BuildSortIndex
   end sub
   sub BuildFromArray(array)
       LoadFromArray array
       SetLabels
       BuildSortIndex
   end sub
   sub LoadFromArray(a)
       dim i,n,line,cat
       for i = lbound(a) to ubound(a)
            line = split(a(i),"^")
            set cat = new invcat
            cat.id = line(0)
            cat.parentid = line(1)
            cat.category = line(2)
            cats.add cat.id, cat
       next
   end sub
      sub LoadFromDB(conn, tableName)
            dim rs, cat
            set rs = server.createobject("ADODB.Recordset")
                  rs.open "select gcID, parentID, gCat from " & tableName & "", conn
                        do while not rs.eof
                              set cat = new invcat
                              cat.id = rs("gcID")
                              cat.parentid = rs("parentID")
                              cat.category = rs("gCat")
                              cats.add clng(cat.id), cat
                              rs.movenext
                        loop
                  rs.close
            set rs = nothing
      end sub
   sub SetLabels
      dim i
      for each i in cats.keys
          cats(i).description = mid(BuildLabel(i),4)
      next
   end sub
   function BuildLabel(id)  
       if id = 0 then
          BuildLabel = ""
          exit function
       else
          dim curcat
          set curcat = cats(id)
          BuildLabel = BuildLabel(curcat.parentid) & " - " & curcat.category
              set curcat = nothing
       end if
   end function
   sub BuildSortIndex
       dim key,descripts,desc
       set descripts = server.createobject("Scripting.Dictionary")
       for each key in cats.keys
           desc = cats(key).description
           if descripts.exists(desc) then
              descripts(desc) = descripts(desc) & "|" & key
           else
              descripts(desc) = key
           end if
       next
       dim sorted
       sorted = split(jssort(descripts.keys), chr(0))
       dim i,n,keys,index
       index = 0
       redim sortindex(cats.count - 1)
       for i = lbound(sorted) to ubound(sorted)
           keys = split(descripts(sorted(i)), "|")
           for n = lbound(keys) to ubound(keys)
              sortindex(index) = keys(n)
              index = index + 1
           next
       next
         set descripts = nothing
   end sub
function SelectBoxWithSelection(selection)
        dim i,out,cat
        out = "<select name=""gcID"">" & vbcrlf
        for i = lbound(sortindex) to ubound(sortindex)
           if cats.exists(clng(sortindex(i))) then
           set cat = cats(clng(sortindex(i)))
                     ll = ""
               if cstr(cat.id) = cstr(selection) then
                    ll=" selected"
               end if
                out = out & "<option value=""" & cat.id & """"&ll&">" & cat.description &"</option>" & vbcrlf
                  set cat = nothing
        end if
        next
        out = out & "</select>" & vbcrlf
        SelectBoxWithSelection = out
  end function
  function SelectBox
     SelectBox = SelectBoxWithSelection("")
  end function
end class
%>
0
 
kevp75Author Commented:
@phil.
I still get the 'Wrong Number of Arguments' error with that last bit you posted
0
 
peh803Commented:
On what line?
0
 
kevp75Author Commented:
line 59...which is:
cats(i).description = mid(BuildLabel(i),4)

from the function above it
0
 
peh803Commented:
okay, so change that to this:
cats(i).description = mid(BuildLabel(i, cats),4)

Thanks,
peh803
0
 
sonicysaCommented:
for passing cats in, you probably need to start all the way back at the first sub called.
so it could get really messy chasing cats all the way back.

in the mean time, did you see if setting it in a session var would help the scoping of it?

session("cats")


I use a session var for a security obj and the scope seems to work.

Set Session("secPermObj") = Server.CreateObject("Scripting.Dictionary")

then on pages that access it:
If IsObject(Session("secPermObj")) Then      
            If Session("secPermObj").exists("userConsole") Then
'--- notice how you have to access items of the dictionary this way though. -------                      
If Session("secPermObj")("userConsole") <> 1 Then             
                            response.redirect("noAccess.asp")              
                      End If
            Else
                      response.redirect("noAccess.asp")           
            End If      
      Else
          response.redirect("noAccess.asp")
          
      End If            

0
 
peh803Commented:
>>I use a session var for a security obj and the scope seems to work.

ugh -- all due respect here, and if your number of users is low, you might be able to get away with this -- BUT -- I've always tried to avoid this.  It's not really considered good practice.  Here's a good discussion of it, with plenty of references to MS articles explaining why it's bad to do this:
http://classicasp.aspfaq.com/components/should-i-store-objects-in-session/application-scope.html
0
 
sonicysaCommented:
why don't you just get rid of the curcat all together. Like I mentioned earler, it is only a reference so it is basically doing nothing for you to use it other than adding confusion.
0
 
kevp75Author Commented:
@phil, added that in and back to the 'Object Required cats(...) error' on set curcat = cats(id)

@sonic
i've no idea what you mean by 'passing in cats'  cats is a disctionary object (or at least supposed to be)
0
 
kevp75Author Commented:
curcat gets me the current category.

look.  this is being called in a file edit page.  so curcat would be the current category the file is in, thus displaying that as selected in the drop-down...
0
 
kevp75Author Commented:
and nothing posted here is telling me why this works on one site, but not on another

as I've said previously in this post.  The exact code I posted in the question works on another site on the same server, in fact it was working on this site as well, up until about last week.  since then it does not work.  No-One has changed any code, it just stopped working.,.,.
0
 
sonicysaCommented:
Thanks for your concern moderator, but for my situation it has worked fine for two years. Aside from putting together a vb com object to do the same thing--which is sometimes a pain when you don't have access to the tools or permissions on the server etc.--the solution is not causing any problems and is no reason not to share the code for the purposes of someone else understanding how it works. Now if I only had time to read through all those pages of information that you suggest that I look at... Oh ya, I think I will try to move on to a different platform anyway since asp is unpredicably unsecure anyway.
0
 
sonicysaCommented:
kevp: to comment at Date: 11/02/2006 11:36AM PST  when you say something like   sub mysub(cats)   you are passing cats into the subroutine.
0
 
sonicysaCommented:
Are you planning on posting the difference between the two servers like I was suggesting? different processor or memory configs? OS ? 2000 vs. 2003 server?
Maybe there was a MSupdate that ran on one server and not the other? There could be all kinds of factors involved but it boils down to old school ASP/vbscript being an unpredictable environment.

0
 
kevp75Author Commented:
please have a good look through my code that I posted sonic, I think you will find that I do not pass cats anywhere, nor is there anything like "sub mysub(cats)"

there is a sub that initilalizes the dictionary object, however....and that would be cats

0
 
kevp75Author Commented:
THERE AREN'T 2 SERVERS!!!!

READ WHAT I POSTED

2 SITES SAME SERVER, SAME CODE
0
 
kevp75Author Commented:
sorry for yelling like that, but it is frustrating enough trying to figure out why this isn't working on one site, when it does on another (same server, same code)
0
 
sonicysaCommented:
So again Kev, don't get frustrated with it.. I am just as frusterated with another asp.net question that I need to ask and don't have any points to ask it yet.. LOL

so try this just as a test. I replaced all cats in the path of the call to "sub BuildFromDB" with a session var instead. that way you could



 <%
class invcat
   dim id, category, parentid, description
end class
class invcats
   dim cats
   dim sortindex()
   sub class_initialize
        set cats = server.createobject("Scripting.Dictionary")
   end sub
   sub class_terminate
        set cats = nothing
   end sub
   sub BuildFromDB(connstr, tableName)
       set session("cats") = server.createobject("Scripting.Dictionary")
       LoadFromDB connstr, tableName
       SetLabels
       BuildSortIndex
   end sub
   sub BuildFromArray(array)
       LoadFromArray array
       SetLabels
       BuildSortIndex
   end sub
   sub LoadFromArray(a)
       dim i,n,line,cat
       for i = lbound(a) to ubound(a)
            line = split(a(i),"^")
            set cat = new invcat
            cat.id = line(0)
            cat.parentid = line(1)
            cat.category = line(2)
            cats.add cat.id, cat
       next
   end sub
     sub LoadFromDB(conn, tableName)
          dim rs, cat
          set rs = server.createobject("ADODB.Recordset")
               rs.open "select gcID, parentID, gCat from " & tableName & "", conn
                    do while not rs.eof
                         set cat = new invcat
                         cat.id = rs("gcID")
                         cat.parentid = rs("parentID")
                         cat.category = rs("gCat")
                         'cats.add clng(cat.id), cat
                         session("cats").add clng(cat.id), cat
                         rs.movenext
                    loop
               rs.close
          set rs = nothing
     end sub
   sub SetLabels
      dim i
      'for each i in cats.keys
      for each i in session("cats").keys
           'cats(i).description = mid(BuildLabel(i),4)
           session("cats")(i).description = mid(BuildLabel(i),4)
      next
   end sub
   function BuildLabel(id)  
       if id = 0 then
          BuildLabel = ""
          exit function
       else
          'dim curcat
          'set curcat = cats(id)
          BuildLabel = BuildLabel(session("cats")(id).parentid) & " - " & session("cats")(id).category
       end if
   end function
   sub BuildSortIndex
       dim key,descripts,desc
       set descripts = server.createobject("Scripting.Dictionary")
       for each key in session("cats").keys
           desc = session("cats")(key).description
           if descripts.exists(desc) then
              descripts(desc) = descripts(desc) & "|" & key
           else
              descripts(desc) = key
           end if
       next
       dim sorted
       sorted = split(jssort(descripts.keys), chr(0))
       dim i,n,keys,index
       index = 0
       redim sortindex(session("cats").count - 1)
       for i = lbound(sorted) to ubound(sorted)
           keys = split(descripts(sorted(i)), "|")
           for n = lbound(keys) to ubound(keys)
              sortindex(index) = keys(n)
              index = index + 1
           next
       next
   end sub
function SelectBoxWithSelection(selection)
        dim i,out,cat
        out = "<select name=""gcID"">" & vbcrlf
          if adminCheck() then
               out = out & "<option value='0'>Root</option>"
          end if
        for i = lbound(sortindex) to ubound(sortindex)
           if cats.exists(clng(sortindex(i))) then
           set cat = cats(clng(sortindex(i)))
                  ll = ""
               if cint(cat.id) = cint(selection) then
                    ll=" selected"
               end if
                out = out & "<option value=""" & cat.id & """"&ll&">" & cat.description &"</option>" & vbcrlf
        end if
        next
        out = out & "</select>" & vbcrlf
        SelectBoxWithSelection = out
  end function
  function SelectBox
     SelectBox = SelectBoxWithSelection("")
  end function
end class
%>
0
 
sonicysaCommented:
Kev, I know that you are not passing it but that was what phil was originally talking about. He was trying to get you to make cats accessable to the recursive functions via passing it in "explicitly".

Sorry, I though you had said or meant two different servers. But still there are some possiblities that even on the same server there are different settings in the two different webs..
do they both have the same configurations? Is one set up in an application pool and one isn't ?? I don't know but there might be all kinds of different configs.

you could try creating two new seperate webs with the default settings and placing the code from the one that works in one and the code from the one that doesn't into the other.. see what you get.
I don't think I will ever consider myself to be an expert at any of this stuff.. In fact I think I will become a personal trainner or something. It's more rewarding. LOL

I don't mind the yelling. is cool.  
0
 
kevp75Author Commented:
Object required: 'session(...)(...)' error on line 73 (BuildLabel = BuildLabel(session("cats")(id).parentid) & " - " & session("cats")(id).category)
0
 
sonicysaCommented:
BTW, did you also try changing the <% out and putting in <script language="vbscript" runat="server">
Like I was saying sometimes the environment gets confused when I tries to use the default lang setting I think. It's a random idea but worth the effort.


0
 
kevp75Author Commented:
i did.  same error
0
 
kevp75Author Commented:
the only difference I found between the 2 sites configurations was the the one with the error was not in an isolated application pool, like the other is.  I switched, however same error
0
 
peh803Commented:
This is definitely goofy -- it's obviously trying to refer to an element in the collection that isn't an object, but we have no idea why it is trying to do this..

I know you said you already tried wrapping an "isObject()" detection around the line -- it should look like this:

   function BuildLabel(id)  
       if id = 0 then
          BuildLabel = ""
          exit function
       else
          'dim curcat
          'set curcat = cats(id)
          if isObject(session("cats")(id)) then
            BuildLabel = BuildLabel(session("cats")(id).parentid) & " - " & session("cats")(id).category
          end if
       end if
   end function

And that gives you the same object expected error?

Thanks,
Phil
0
 
kevp75Author Commented:
same error
0
 
sonicysaCommented:
could be that the app pool setting change doesn't take place until a reboot.??
0
 
sonicysaCommented:
It's like the app pool setting keeps object references under different kind of control.

since it was working though in this web was it added to an app pool after it was initially working?
I mean when it was initially working was it in the seperate app pool?
0
 
kevp75Author Commented:
i restarted IIS, i'll brb as I restart the server.

it was working when it was in the initial app pool though
0
 
sonicysaCommented:
Back at the moderator... Why is it that the login for experts-exchange is not https ? if you guys are so concern about best practice??
0
 
peh803Commented:
Which moderator are you talking to?  I don't see any moderator comments in here...?

Phil / peh803
0
 
kevp75Author Commented:
k....server is restarted...same issue

both sites have the same exact code, the same exact settings (minus the root folder)
0
 
kevp75Author Commented:
give me just a few minutes, I will setup a test page on both sites
0
 
sonicysaCommented:
LOL, I guess that for some reason my post took more time to show up than yours phil. I thought that the session stuff got blocked. Im new at this ee system anyway.

I am trying to set up your code in a test environment so I can experiment with it Kev.

0
 
kevp75Author Commented:
2 test pages:
http://www.getmysupport.com/temp.asp   <--the non-working one
http://www.portalfanatic.com/temp.asp     <--the working one

both use the same code, both use the same table structure in a MS SQL db (2 different db's though), both are on the same server
0
 
peh803Commented:
>>2 different db's though

Can you try pointing them both at the same DB to see if you still get the same error?  That way, we can rule this out as a potential source of variability.

Thanks,
Phil
0
 
peh803Commented:
okay, and the file we're looking at, I Assume (dumb question, probably) is the file /includes/inc/specialdb.asp, right?

Thanks,
Phil

0
 
kevp75Author Commented:
that's the code in the question....I'll set them to point at the same server....
0
 
kevp75Author Commented:
i'll be dipped.

when I point to the SQL Server for the portalfanatic.com one (the one that works)

both work

now this is getting real confusing....both servers have the same table structure...
0
 
peh803Connect With a Mentor Commented:
How about the contents of the tables that load the collection?  I'll bet those aren't the same...
0
 
kevp75Author Commented:
when I point them to the other SQL server neither works....
0
 
kevp75Author Commented:
no, they both have different content
0
 
peh803Commented:
At least we're closer to figuring out what the heck is going on!
0
 
peh803Connect With a Mentor Commented:
okay -- so now, do some debugging around the load from DB function and see what's being selected (if anything) From the db that's not working...

for example, write out the SQL statement and execute it manually against each SQL server in query analyzer... see whatcha get..
0
 
kevp75Author Commented:
ok.  Did that, and they both work
0
 
sonicysaCommented:
or use sqlprofiler to see what the query is as it gets posted to the sqlserver.
I have found that tool shows things you don't see from the asp.net code side of things... Not that that info matters for this situation or old style asp as much.

0
 
sonicysaCommented:
I have entered data up to gcID 8 though and it is still running through the code just fine.
0
 
peh803Commented:
I agree with @sonicysa -- generally, sqlprofiler is an awesome tool to use -- however, if you don't have admin rights to the SQL Server in question, you may not be able to do this.  
0
 
peh803Commented:
>>Did that, and they both work

They both return data sets that have records?  We know that there's something odd in the one database that is causing this issue -- the trick now is just finding out what it is.

Regards,
Phil
0
 
sonicysaConnect With a Mentor Commented:
28     Open Office     3     0     27
29     Microsoft Office     3     0     27


both of these might be issues. How is your delete function working? maybe it is not properly removing related entries and thus orphaning data.
0
 
sonicysaCommented:
That is definitly the issue. once I added those rows into the db I then got the error.
0
 
kevp75Author Commented:
i'll be a monkey's uncle sonic!

got rid of those 2 rows and it now works....da^% it all, looks like I have to re-write my category deleter.  Those 2 were referencing a Top category that did exist at one time, but I deleted it....

thank you both...for dealing with me   ;-)
0
 
sonicysaCommented:
no problem. It was interesting figuring out how best to help from a discussion board. Usually I am the one asking for help. Hopefully it will help me in asking the questions better in the future.
0
 
peh803Commented:
glad to help, but some points for the effort would have been nice, esp. since I pushed us towards looking @ the db in the 1st place... :-P

Anyways, good luck moving forward..

Phil
0
 
peh803Commented:
DOH!

Sorry, I just saw that you did give me an assist -- really sorry, I just hadn't received the email yet, and hadn't looked up in the thread to see it.

Apologies and thanks...
Phil
0
 
kevp75Author Commented:
:)
0
All Courses

From novice to tech pro — start learning today.