Multiple select values to a database

Results 1 to 3 of 3

Thread: Multiple select values to a database

  1. #1
    Join Date
    Dec 1969

    Default Multiple select values to a database

    I have a form that is adding records to a database. There is a multiple select box on the form. When I call the asp page, though, I can&#039t seem to get all of the values to the database. I know what the problem is, but I don&#039t know how to correct it. Below is my code. In my FOR loop, I am just overwriting the RSObj("eventsProducts") each time, so it will only store the last one. How do I change that to keep adding on, rather than just take the last one(x). <BR>Any help is greatly appreciated, and thank you in advance.<BR><BR>My code:<BR>&#060;%<BR>Set ConnObj=Server.CreateObject("ADODB.Connection")<BR >Set RSObj=Server.CreateObject("ADODB.Recordset")<BR>SQ L_query="Select * From eventsCalendar Where eventsID=0"<BR>RSObj.Open SQL_query,"DBQ=j:wwwtestdatabaseseventsevents.mdb; DRIVER=Microsoft Access Driver (*.mdb)",3,3<BR><BR>RSObj.AddNew<BR>RSObj("eventsS tartDate")=Request.Form("startdate")<BR>RSObj("eve ntsEndDate")=Request.Form("enddate")<BR>RSObj("eve ntsName")=Request.Form("name")<BR>RSObj("eventsLoc ation")=Request.Form("location")<BR>RSObj("eventsS ponsor")=Request.Form("sponsor")<BR>RSObj("eventsC ontact")=Request.Form("contact")<BR>RSObj("eventsC ontactEmail")=Request.Form("contactemail")<BR>RSOb j("eventsType")=Request.Form("type")<BR>RSObj("eve ntsClassification")=Request.Form("class")<BR><BR>I f Request.Form("products").count &#062; 1 then<BR> for x=1 to Request.Form("products").count<BR> RSObj("eventsProducts")= Request.Form("products")(x)<BR> next<BR>Else<BR> RSObj("eventsProducts")=Request.Form("products")<B R>End If<BR><BR>RSObj("eventsDetail")=Request.Form("desc ")<BR>RSObj.Update<BR><BR>%&#062;

  2. #2
    JOseph Hatcher Guest

    Default RE: Multiple select values to a database

    Not sure if this is what you want or not but if Request.Form("products") is numbers then<BR><BR>dim value<BR>value=0<BR>If Request.Form("products").count &#062; 1 then<BR>for x=1 to Request.Form("products").count<BR>value= value&Request.Form("products")(x)<BR>next<BR>RSObj ("eventsProducts")=value<BR>Else<BR>RSObj("eventsP roducts")=Request.Form("products")<BR>End If<BR><BR><BR><BR><BR>if Request.Form("products") is strings then<BR><BR><BR>dim value<BR>value=""<BR>If Request.Form("products").count &#062; 1 then<BR>for x=1 to Request.Form("products").count<BR>value= Request.Form("products")(x)+value<BR>next<BR>RSObj ("eventsProducts")=value<BR>Else<BR>RSObj("eventsP roducts")=Request.Form("products")<BR>End If<BR><BR>

  3. #3
    David Costelloe Guest

    Default RE: Multiple select values to a database

    Hello,<BR>You are missing the MoveNext for the recordset, this explains why you only get the last record.<BR>For X=1 to Request.Form("products").Count<BR> RSobj("eventsProducts") = Request.Form("products") (X)<BR> RSobj.MoveNext &#039go to the next record<BR>Next<BR>Else ....... yada yada<BR><BR>Hope this helps<BR>david.....

Posting Permissions

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