Join() and Array with Null

Discussion in 'ASP General' started by !TG, Aug 2, 2005.

  1. !TG

    !TG Guest

    I recently learned of Join
    response.write join(ThisArray," ")

    I am having trouble with it, however and it appears to be caused by null
    characters.

    Is there anyway around this join problem with Arrays containing Null?
    !TG, Aug 2, 2005
    #1
    1. Advertising

  2. What trouble? What? Can you give us code and errors?

    Ray at work

    "!TG" <> wrote in message
    news:...
    > I recently learned of Join
    > response.write join(ThisArray," ")
    >
    > I am having trouble with it, however and it appears to be caused by null
    > characters.
    >
    > Is there anyway around this join problem with Arrays containing Null?
    Ray Costanzo [MVP], Aug 2, 2005
    #2
    1. Advertising

  3. !TG

    !TG Guest

    Ray Costanzo [MVP] wrote:
    > What trouble? What? Can you give us code and errors?
    >
    > Ray at work
    >
    > "!TG" <> wrote in message
    > news:...
    >
    >>I recently learned of Join
    >>response.write join(ThisArray," ")
    >>
    >>I am having trouble with it, however and it appears to be caused by null
    >>characters.
    >>
    >>Is there anyway around this join problem with Arrays containing Null?

    >
    >
    >

    I am very sorry!

    Error is Type mismatch: 'join'

    Code example is:

    Fields = Array("Name","Address","HomePhone",Null)
    Dim FieldList
    FieldList = cstr(join(Fields,","))

    I also tried it without the cstr
    !TG, Aug 2, 2005
    #3
  4. It seems that Join cannot handle nulls as you expected. Where is the null
    value coming from? Can you get rid of it when you're creating your array?
    How is your array being built. In this particular sample code, you could
    do:

    Fields = Array("Name", "Address", "HomePhone", Null & "")
    Dim FieldList
    FieldList = CStr(Join(Fields, ","))

    Ray at work


    "!TG" <> wrote in message
    news:...
    > Error is Type mismatch: 'join'
    >
    > Code example is:
    >
    > Fields = Array("Name","Address","HomePhone",Null)
    > Dim FieldList
    > FieldList = cstr(join(Fields,","))
    >
    > I also tried it without the cstr
    Ray Costanzo [MVP], Aug 2, 2005
    #4
  5. !TG

    !TG Guest

    Ray Costanzo [MVP] wrote:
    > It seems that Join cannot handle nulls as you expected. Where is the null
    > value coming from? Can you get rid of it when you're creating your array?
    > How is your array being built. In this particular sample code, you could
    > do:
    >
    > Fields = Array("Name", "Address", "HomePhone", Null & "")
    > Dim FieldList
    > FieldList = CStr(Join(Fields, ","))
    >
    > Ray at work
    >
    >


    The array is built fromform fields submitted to an ASP which loads
    fields into arrays to update a database.

    There are about 100 fields from various databases with the html forms
    across 7 or 8 pages, that use that function.
    I built a system for my company that keeps track of employee information
    and I am trying to create a database of changes when they are made, by
    whom, and to what users, so I can guard against or at least track rogue
    users down, should the need arrise.
    !TG, Aug 2, 2005
    #5
  6. !TG wrote:
    > Ray Costanzo [MVP] wrote:
    >> It seems that Join cannot handle nulls as you expected. Where is
    >> the null value coming from? Can you get rid of it when you're
    >> creating your array? How is your array being built. In this
    >> particular sample code, you could do:
    >>
    >> Fields = Array("Name", "Address", "HomePhone", Null & "")
    >> Dim FieldList
    >> FieldList = CStr(Join(Fields, ","))
    >>
    >> Ray at work
    >>
    >>

    >
    > The array is built fromform fields submitted to an ASP which loads
    > fields into arrays to update a database.
    >

    So, when you populate the array, concatenate an empty string to the values
    coming from the database.

    Bob barrows
    --
    Microsoft MVP -- ASP/ASP.NET
    Please reply to the newsgroup. The email account listed in my From
    header is my spam trap, so I don't check it very often. You will get a
    quicker response by posting to the newsgroup.
    Bob Barrows [MVP], Aug 2, 2005
    #6
  7. !TG

    !TG Guest

    Bob Barrows [MVP] wrote:
    > !TG wrote:
    >
    >>Ray Costanzo [MVP] wrote:
    >>
    >>>It seems that Join cannot handle nulls as you expected. Where is
    >>>the null value coming from? Can you get rid of it when you're
    >>>creating your array? How is your array being built. In this
    >>>particular sample code, you could do:
    >>>
    >>> Fields = Array("Name", "Address", "HomePhone", Null & "")
    >>> Dim FieldList
    >>> FieldList = CStr(Join(Fields, ","))
    >>>
    >>>Ray at work
    >>>
    >>>

    >>
    >>The array is built fromform fields submitted to an ASP which loads
    >>fields into arrays to update a database.
    >>

    >
    > So, when you populate the array, concatenate an empty string to the values
    > coming from the database.
    >
    > Bob barrows

    There are too many different places that Null could be loaded into an array.
    Can I replace Null with empty in arrays after the fact?
    I've tried For Next loops before to do something similar but never had
    any luck with arrays.
    !TG, Aug 3, 2005
    #7
  8. !TG wrote:
    >>
    >> So, when you populate the array, concatenate an empty string to the
    >> values coming from the database.
    >>
    >> Bob barrows

    > There are too many different places that Null could be loaded into an
    > array. Can I replace Null with empty in arrays after the fact?


    Yes, but then you'll have the same problem: "too many places"

    > I've tried For Next loops before to do something similar but never had
    > any luck with arrays.


    You should consider rewriting your queries that retrieve the data to be used
    for these arrays to prevent the retrieval of nulls.Most versions of sql
    include functions to allow you to replace nulls with empty strings or
    whatever. In SQL Server's Transact-SQL you can use COALESCE or ISNULL. With
    Access you can use the VBA "immediate if" function: iif()

    Bob Barrows
    --
    Microsoft MVP -- ASP/ASP.NET
    Please reply to the newsgroup. The email account listed in my From
    header is my spam trap, so I don't check it very often. You will get a
    quicker response by posting to the newsgroup.
    Bob Barrows [MVP], Aug 3, 2005
    #8
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    5
    Views:
    26,498
    Mike Schilling
    Mar 29, 2006
  2. Alan Silver
    Replies:
    0
    Views:
    871
    Alan Silver
    Jun 5, 2006
  3. googleboy
    Replies:
    1
    Views:
    908
    Benji York
    Oct 1, 2005
  4. aneuryzma
    Replies:
    3
    Views:
    692
    Jim Langston
    Jun 16, 2008
  5. Tradeorganizer

    how to join array into array

    Tradeorganizer, May 6, 2007, in forum: Perl Misc
    Replies:
    12
    Views:
    221
    Michele Dondi
    May 11, 2007
Loading...

Share This Page