Taking apart a URL/Multiple Database Inserts/

Results 1 to 2 of 2

Thread: Taking apart a URL/Multiple Database Inserts/

  1. #1
    Join Date
    Dec 1969

    Default Taking apart a URL/Multiple Database Inserts/

    i have a search page which returns an X number of items. what i am trying to do is allow a user to select as many items on that page as they want by the use of a CHECKBOX...then they click on the Submit button to add these items into a database..and this is where i am getting stuck.<BR>the info that is being passed by the CHECKBOX is an ID thats in database ABC..i need to retreive this ID from database ABC and then insert the retreived info into datatbase XYZ...thats fine if there is only 1 id being passed..but what if the user selects 2 or more items..how do i get the ids seperated and then how do i query the database...<BR><BR>what i tried.<BR>through i could use the SPLIT function and split the URL Query String into smaller parts and then just extract the IDS..<BR>so take id1=12&id2=35<BR>i was able to split using the &...<BR>id1=12<BR>id2=35<BR>but i cant figure out how to now split again but this time using the =. that way i have 4 items in the array instead of 2.<BR>id1<BR>12<BR>id2<BR>35<BR><BR>if anyone can guide me in the right direction on this issue i would greatly appreciate it.

  2. #2
    Join Date
    Dec 1969

    Default Give *all* the checkboxes same name...

    ..and then you just do:<BR><BR>&#060;%<BR>all = Request("OneAndOnlyCheckboxName")<BR>ids = Split( all, ", " ) &#039; that is a COMMA-SPACE that you split on<BR>For i = 0 To UBound(ids)<BR> oneID = ids(i)<BR> ... insert this ID ...<BR>Next<BR>%&#062;<BR><BR>HOWEVER... If you really are using two tables (even in two DBs, though why two DBs I don&#039;t get), you can *probably* do this even simpler, assuming you give all checkboxes the same name:<BR><BR>&#060;%<BR>&#039; assuming you open the connection to XYZ:<BR>&#039;<BR>SQL = "INSERT INTO table1 ( field1, field2, field3 ) " _<BR> & " SELECT fieldA, fieldB, fieldC FROM table2 IN ABC.mdb " _<BR> & " WHERE id IN (" & Request("CheckboxesName") & ")"<BR><BR>connectionToXYZ.Execute( SQL )<BR>%&#062;<BR><BR>Presto, done.<BR><BR>See this:<BR>http://www.aspfaqs.com/aspfaqs/ShowFAQ.asp?FAQID=153<BR><BR>If you aren&#039;t using Access DBs, you can still do this with SQL Server though the syntax to "hit" the second DB is a bit different.<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