how to handle this data...

Results 1 to 10 of 10

Thread: how to handle this data...

  1. #1

    Default how to handle this data...

    I have a value of which is being passed from one page to another within a form. The name of this value is "equipment". Actually the form value is a series of checkboxes of which the user may select from. Each checkbox although it has the same name, has a different value. <BR><BR>Heres my question...when the form is passed to the next page, I have one form object that contains many values. If I write it to screen I get this...<BR><BR>CODE<BR>response.write request.form("equipment")<BR><BR>OUTPUT<BR>3,7,15, 21 etc and so on.<BR><BR>My questions are this...<BR>1. Can I store these values straight into the db as they are?<BR><BR>2. How do I write an SQL statement to sort through each entry and ignore the commas? <BR><BR>Thanks,<BR>John

  2. #2
    Join Date
    Dec 1969

    Default RE: how to handle this data...

    Use Split() to get it as an array, then iterate through it and insert the items individually. Alternatively (if you&#039;re using SQL Server), you could build up semi-colon delimited SQL commands, and execute them all at the end...<BR><BR>It&#039;s up to you.<BR><BR>Craig.

  3. #3

    Default ok...any chance you could

    give a demo on how to do this?<BR><BR>Use Split() to get it as an array..<BR><BR>And how would I write the SQL statement?<BR><BR>Thanks again

  4. #4
    Join Date
    Dec 1969

    Default RE: ok...any chance you could

    Click the VBScript Reference link on the left for full information of all the functions in VBScript, including the Split() function.<BR><BR>Craig.

  5. #5

    Default thanks craig...I hope I

    can find what im looking for.<BR><BR>John

  6. #6

    Default Craig, I have looked at the examples, but

    theyre a little out of my league. I dont really understand whats going on in those example or how to apply them.<BR><BR>John

  7. #7
    Join Date
    Dec 1969

    Default RE: Craig, I have looked at the examples, but

    How long have you been doing this...? Come on...<BR><BR>Look, which bit EXACTLY is giving you a problem? Have you worked out your logic flow? What you&#039;re going to actually do? Step-by-step?<BR><BR>You should be able to work it out from the previous post I made. Ok, look, here&#039;s a quick one:<BR><BR>1) Read in the string<BR>2) Use the Split() function to get an array<BR>3) Use a counter to iterate through the array<BR>4) Execute a SQL query.<BR><BR>Is it that you don&#039;t understand arrays? Is that the problem?<BR><BR>Craig.

  8. #8

    Default A simple example ...

    ...would have been fine. Its my first go at arrays.<BR><BR>Ill go back to the msdn site.<BR><BR>Thanks anyway

  9. #9
    Join Date
    Dec 1969

    Default RE: A simple example ...

    That&#039;s all you had to say. Arrays are like simple tables. A normal array (1 dimensional, as you get from Split()), could be thought of like a row in a table.<BR><BR>&#060;%<BR>&#039;Get string<BR>Dim sMyString: sMyString = "1,2,3"<BR>&#039; Get array<BR>Dim aMyArray: aMyArray = Split(sMyString, ",")<BR>%&#062;<BR>&#060;%<BR>Dim intCounter &#039; Just declare the variable.<BR>&#039; Arrays start at zero.<BR>For intCounter = 0 To UBound(aMyArray)<BR> &#039; UBound() is a function that gets the upper bound of an array<BR> &#039; Each individual entry is aMyArray(intCounter).<BR> &#039; As we go through, intCounter gets increased, so we get a new part of the array...!<BR> sMyQuery = "INSERT INTO x (y) VALUES (" & aMyArray(intCounter) & ")"<BR> &#039; Execute it...<BR>Next<BR>%&#062;<BR><BR>Does that help at all?<BR><BR>Craig.

  10. #10

    Default Yes it does, I probably

    should have pointed out that this was my first attempt at handling arrays...<BR><BR>My apologies for the misunderstanding. <BR><BR>Thanks for your patience,<BR>Regards,<BR>John

Posting Permissions

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