Help with arrays!

Results 1 to 2 of 2

Thread: Help with arrays!

  1. #1
    Join Date
    Dec 1969

    Default Help with arrays!

    Help Please! I have am attemtping to update data via a stored procedure to a SQL database from a web form. The problem is that (for reasons I won&#039t go into) I have to allow multiple values to be passed from the form fields, but the stored procedure parameter will only accept one value and not a string of values followed by commas.(see example for how data is coming from the form fields) Someone told me that I might be able to use an array and the split command to get this string of values into a format where they will be passed to the parameter one at a time, but I have not figured out how to do it. Please help!!<BR>Thank you in advance!<BR> <BR>Example of format data is coming in from forms:<BR><BR>Request.Form("goalid") = 1,4,5,3<BR>Request.Form("Goal_Status") = item1,item2,item3<BR><BR><BR>Example of how form value is being passed to paramater:<BR><BR>cmdProc.Parameters("@goal_ID") = Request.Form("goalid")<BR>cmdProc.Parameters("@act ive") = Request.Form("Goal_Status")<BR><BR><BR><BR><BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: Help with arrays!

    You have to use a loop:<BR><BR>&#060;%<BR>goalids = Split( Request.Form("goalid"), ", " )<BR>For gnum = 0 To UBound( goalids )<BR> &nbsp; ... set up cmdProc ...<BR> &nbsp; cmdProc.Parameters("@goal_ID") = goalids(gnum)<BR> &nbsp; ... execute the proc ...<BR>Next<BR>%&#062;<BR><BR>Of course, you could probably also write a custom stored procedure that could iterate through the elements of a comma delimited string, but if you must use the stored procedures you already have, then you&#039ll have to do a loop in VBS.<BR><BR><BR><BR>

Posting Permissions

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