Professional Web Applications Themes

Passing Dictionary object byref - ASP Database

Passing Dictionary object byref 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 ...

  1. #1

    Default Passing Dictionary object byref

    Passing Dictionary object byref

    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
    Ryan Malone Guest

  2. #2

    Default Passing Dictionary object byref

    Passing Dictionary object byref

    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
    Ryan Malone Guest

  3. #3

    Default Re: Passing Dictionary object byref

    Are you looking at the right line in the right page? Like, is
    classlcDocTKit_item.asp an include file perhaps, and you're looking at line
    52 in the page with the include directive instead?

    Ray at work

    "Ryan Malone" <ryanswebsitehotmail.com> wrote in message
    news:e8386b53.0309150055.f36d9e6posting.google.co m...
    >
    > 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

    Ray at Guest

  4. #4

    Default Re: Passing Dictionary object byref

    [url]http://www.aspfaq.com/5003[/url]

    Ray at work

    "Ryan Malone" <ryanswebsitehotmail.com> wrote in message
    news:e8386b53.0309150056.4c30338posting.google.co m...
    > Passing Dictionary object byref
    >

    Ray at Guest

  5. #5

    Default Re: Passing Dictionary object byref

    Hi Ray

    Thanks for the reply, the code that ive included is from
    classlcDocTKit_item.asp. It has got me completely stumped.



    "Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message news:<eP9MFg4eDHA.2332TK2MSFTNGP12.phx.gbl>...
    > Are you looking at the right line in the right page? Like, is
    > classlcDocTKit_item.asp an include file perhaps, and you're looking at line
    > 52 in the page with the include directive instead?
    >
    > Ray at work
    >
    > "Ryan Malone" <ryanswebsitehotmail.com> wrote in message
    > news:e8386b53.0309150055.f36d9e6posting.google.co m...
    >
    > >
    > > 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
    Ryan Malone Guest

  6. #6

    Default Passing Dictionary object byref

    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

    -----------------------------
    This message is posted by [url]http://Asp.ForumsZone.com[/url]

    Guest

  7. #7

    Default Re: Passing Dictionary object byref

    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
    [email]mschuppielearning.com[/email]
    [url]http://www.ielearning.com[/url]
    714.637.9480 x17


    <ryanlawcentral.com.au> wrote in message
    news:307276501046384Asp.ForumsZone.com...
    > 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
    >
    > -----------------------------
    > This message is posted by [url]http://Asp.ForumsZone.com[/url]
    >

    Mark Schupp Guest

  8. #8

    Default Re: Passing Dictionary object byref

    Thank you Mark you are a legend.

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




    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    Ryan Malone Guest

Similar Threads

  1. ASP: Can Dictionary object store arrays or recordsets as items?
    By Ken Fine in forum Dreamweaver AppDev
    Replies: 0
    Last Post: April 12th, 11:28 PM
  2. Dictionary Object
    By Johnny Klunk in forum ASP
    Replies: 15
    Last Post: February 26th, 03:28 PM
  3. Passing an object
    By Aaron Murray in forum PHP Development
    Replies: 3
    Last Post: February 4th, 07:31 PM
  4. Replies: 0
    Last Post: June 30th, 09:28 PM
  5. Dictionary Object Replacement
    By Vicky S in forum ASP.NET Web Services
    Replies: 2
    Last Post: June 26th, 03:12 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139