Passing Dictionary object byref

G

Guest

Ive created an ASP class that uses a dictionary object which is filled from a recordset. It passes the object to the propterty of another ASP class byref:

Public Property Let dicReplaceVars(byref vdicReplaceVars)
set p_ReplaceVars = vdicReplaceVars
End Property


Private p_ReplaceVars


where it is used in this other class a few times to replace values in an array:

Function ReplaceVars(vArrayItem)

'' turn it into an array split at spaces
vArrayItem = split(vArrayItem," ")
'' loop through the array
for count = lbound(vArrayItem) to ubound(vArrayItem)

''See if it is a replacement variable and exists in the dictionary
if left(vArrayItem(count),6) = "tkRep_" and
p_ReplaceVars.exists(vArrayItem(count)) then
'' then replace it
Error occurs here >> vArrayItem(count) =
p_ReplaceVars.Item(cstr(vArrayItem(count)))
end if
next

dim vArrayItemNew
vArrayItemNew = ""

'' Loop through the array and put it back together
for count = lbound(vArrayItem) to ubound(vArrayItem)

if vArrayItem(count) = ubound(vArrayItem) then
vArrayItemNew = vArrayItemNew & vArrayItem(count)
else
vArrayItemNew = vArrayItemNew & vArrayItem(count) & " "
end if
next

'' return the vArrayItemNew to the function
ReplaceVars = vArrayItemNew
End Function

The error message I get is:

ADODB.Field (0x800A0D5C)
Object is no longer valid. D:\WWW\LCDEV\DOC_FUNCTIONS\../classes/classlcDocTKit_item.asp, line 52

However I have no idea why, it is a dictionary object and not a recordset, the object should still be open.

Any help is greatly appreciated.

Thanks
 
M

Mark Schupp

When you set the data into the dictionary object from the recordset make
sure you use the value. ie:

rsdata("mycol").value

not

rsdata("mycol")

which returns a field object, not the field's value.


--
Mark Schupp
--
Head of Development
Integrity eLearning
Online Learning Solutions Provider
(e-mail address removed)
http://www.ielearning.com
714.637.9480 x17


Ive created an ASP class that uses a dictionary object which is filled
from a recordset. It passes the object to the propterty of another ASP class
byref:
Public Property Let dicReplaceVars(byref vdicReplaceVars)
set p_ReplaceVars = vdicReplaceVars
End Property


Private p_ReplaceVars


where it is used in this other class a few times to replace values in an array:

Function ReplaceVars(vArrayItem)

'' turn it into an array split at spaces
vArrayItem = split(vArrayItem," ")
'' loop through the array
for count = lbound(vArrayItem) to ubound(vArrayItem)

''See if it is a replacement variable and exists in the dictionary
if left(vArrayItem(count),6) = "tkRep_" and
p_ReplaceVars.exists(vArrayItem(count)) then
'' then replace it
Error occurs here >> vArrayItem(count) =
p_ReplaceVars.Item(cstr(vArrayItem(count)))
end if
next

dim vArrayItemNew
vArrayItemNew = ""

'' Loop through the array and put it back together
for count = lbound(vArrayItem) to ubound(vArrayItem)

if vArrayItem(count) = ubound(vArrayItem) then
vArrayItemNew = vArrayItemNew & vArrayItem(count)
else
vArrayItemNew = vArrayItemNew & vArrayItem(count) & " "
end if
next

'' return the vArrayItemNew to the function
ReplaceVars = vArrayItemNew
End Function

The error message I get is:

ADODB.Field (0x800A0D5C)
Object is no longer valid.
D:\WWW\LCDEV\DOC_FUNCTIONS\../classes/classlcDocTKit_item.asp, line 52
However I have no idea why, it is a dictionary object and not a recordset,
the object should still be open.
 
R

Ryan Malone

Thank you Mark you are a legend.

Solved my problem immediately, it was causing all sorts of weird things
to happen
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,528
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top