Comma delimited array into DB problems

Ask a Question related to ASP Database, Design and Development.

  1. #1

    Default Comma delimited array into DB problems

    Hi,

    I have an asp page that takes input from a form on the previous page,
    puts that into an array and inserts the array into SQL server.

    Now here is the problem:

    The form on the page where the user can enter information contains a
    dynamic amount of text boxes with the same name. So when the user
    submits their entry, I get a comma delimited string.

    e.g. First entry, Second entry, Third entry

    The problem comes when a user enters a comma in the text field

    e.g. First entry, with a comma, Second entry, Third Entry.

    My code will put "with a comma" into a different row in the DB than
    "First entry" because of the comma in the string.

    Any ideas on how to solve this?


    CODE (somewhat simplified)

    Detailsvar = request("details")
    details = Replace(Detailsvar, "'", "''") 'array

    Dim deArray
    deArray = Split(details, ", ")

    FOR i = Lbound(deArray) TO Ubound(deArray)
    DB.Execute("sp_insert_ratings '" & deArray(i) & "'")
    NEXT

    Arne



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

  2. Similar Questions and Discussions

    1. query against comma delimited field
      I can't seem to find out how to do this correctly. I have a field with comma delimited text that I need to query against to find a match. ...
    2. Reading a Comma Delimited File
      Hello all, So as the title says, I need to read a comma delimited file generated by MS Excel. I know that by doing GetListAt() or ListLen()...
    3. comma delimited list problem
      I have a comma delimited list that is loaded into flash using loadvars. How can I convert it into an array? thanks in advance. Shaun
    4. Splitting Comma delimited list
      Hello everyone, I use the following to split a comma delimited list and get varying results and I don't understand why. my count of the...
    5. generate CSV or comma delimited
      What's the easiest way to generate CSV or a comma delimited file from an ASP recordset? I've seen a few searching the internet and they appear to be...
  3. #2

    Default Re: Comma delimited array into DB problems

    Please do not multipost.

    Ray at work

    "Arne de Booij" <a_de_booij@hotmail.com> wrote in message
    news:uZZtQCv7DHA.4060@tk2msftngp13.phx.gbl...
    > Hi,
    >
    > I have an asp page that takes input from a form on the previous page,
    > puts that into an array and inserts the array into SQL server.
    >
    > Now here is the problem:
    >
    > The form on the page where the user can enter information contains a
    > dynamic amount of text boxes with the same name. So when the user
    > submits their entry, I get a comma delimited string.
    >
    > e.g. First entry, Second entry, Third entry
    >
    > The problem comes when a user enters a comma in the text field
    >
    > e.g. First entry, with a comma, Second entry, Third Entry.
    >
    > My code will put "with a comma" into a different row in the DB than
    > "First entry" because of the comma in the string.
    >
    > Any ideas on how to solve this?
    >
    >
    > CODE (somewhat simplified)
    >
    > Detailsvar = request("details")
    > details = Replace(Detailsvar, "'", "''") 'array
    >
    > Dim deArray
    > deArray = Split(details, ", ")
    >
    > FOR i = Lbound(deArray) TO Ubound(deArray)
    > DB.Execute("sp_insert_ratings '" & deArray(i) & "'")
    > NEXT
    >
    > Arne
    >
    >
    >
    > *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    > Don't just participate in USENET...get rewarded for it!

    Ray at Guest

  4. #3

    Default Re: Comma delimited array into DB problems

    "Arne de Booij" <a_de_booij@hotmail.com> wrote in message
    news:uZZtQCv7DHA.4060@tk2msftngp13.phx.gbl...
    > Hi,
    >
    > I have an asp page that takes input from a form on the previous page,
    > puts that into an array and inserts the array into SQL server.
    >
    > Now here is the problem:
    >
    > The form on the page where the user can enter information contains a
    > dynamic amount of text boxes with the same name. So when the user
    > submits their entry, I get a comma delimited string.
    >
    > e.g. First entry, Second entry, Third entry
    >
    > The problem comes when a user enters a comma in the text field
    >
    > e.g. First entry, with a comma, Second entry, Third Entry.
    >
    > My code will put "with a comma" into a different row in the DB than
    > "First entry" because of the comma in the string.
    >
    > Any ideas on how to solve this?
    >
    >
    > CODE (somewhat simplified)
    >
    > Detailsvar = request("details")
    > details = Replace(Detailsvar, "'", "''") 'array
    >
    > Dim deArray
    > deArray = Split(details, ", ")
    >
    > FOR i = Lbound(deArray) TO Ubound(deArray)
    > DB.Execute("sp_insert_ratings '" & deArray(i) & "'")
    > NEXT
    >
    > Arne
    >
    >
    >
    > *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    > Don't just participate in USENET...get rewarded for it!
    [url]http://groups.google.com/groups?selm=e28zW%24p5DHA.2736%40TK2MSFTNGP09.phx. gbl[/url]


    Chris Hohmann Guest

  5. #4

    Default Re: Comma delimited array into DB problems

    trap and convert the inputted text with comma using replace

    ‚ = comma

    mytext = replace(mytext,",","‚")
    Unregistered Guest

Posting Permissions

  • You may not post new threads
  • You may 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