Can THIS be done? Tricky insert issue...

Results 1 to 3 of 3

Thread: Can THIS be done? Tricky insert issue...

  1. #1
    Join Date
    Dec 1969

    Default Can THIS be done? Tricky insert issue...

    Hey. Let me make this easy.<BR><BR>I have one form. And one of the fields is "category"<BR><BR>It is a pulldown menu. Let&#039s say 3 options:<BR>Book<BR>Cd<BR>Soundtrack<BR><BR>Ok, to display info, I pull from 3 different tables in my db<BR>Book<BR>Cd<BR>Soundtrack<BR><BR>It makes life easy and organized. Here is the question.<BR>Can I do an if/then to make sure that <BR>IF the category = book, then insert to book table<BR>or<BR>If category = cd then insert into CD<BR><BR>WHILE THE OTHER QUESTIONS GO TO THE SAME TABLE<BR>Info<BR><BR>So, if there are 5 questions, 4 go to table Info<BR>ONLY category is the one I want to manipulate if need be.<BR><BR>Can I do that?<BR><BR>Or do I need separate forms for each category?<BR><BR>Thanks<BR><BR>

  2. #2
    SPG Guest

    Default Something like this?

    Yes.<BR><BR>foo = request.form("dropDown")<BR>if foo = "a" then<BR> foo = "a"<BR>elseif foo = "b" then<BR> foo = "b"<BR>else<BR> foo = "c"<BR>end if<BR><BR>objConn.execute "insert into " & foo & " (col1, col2) values (&#039" & val1 & "&#039, &#039" & val2 & "&#039)"<BR><BR>You&#039re probably really just looking for the last line. If that&#039s not what you&#039re looking for, your verbiage is too confusing for my poor addled brain.<BR><BR>HiH.

  3. #3
    Join Date
    Dec 1969

    Default RE: Something like this?

    I don&#039t know.<BR><BR>It&#039s easy, but it&#039s not.<BR><BR>Here&#039s the thing. The logic is what I am working on.<BR><BR>Basically, imagine display.asp having 3 text headers listed.<BR><BR>Books<BR><BR>Cds<BR><BR>Soundtracks <BR><BR>Under Each column the recordsets are placed. I can do that now if I pull from multiple tables, meaning EACH column has recordsets under it from a separate table. Ie Soundtracks has recofdsets under it from soundtrack table and so on.<BR><BR>So, to get the data to the tables, I want to have my pull down menu on my form, named "cateogry" determine WHICH table to insert into based on value.<BR><BR>If there are 3 values:<BR>Cd, Books, Soundtrack, I want to use an if then to say:<BR><BR>Ok, if cd is chosen then put this value in cd table.<BR>If Books, than put into books.<BR><BR>And so on. This way when they do a search, each category on display.asp has a dynamic listing of recordsets under each appropriate category.<BR><BR>My dielma is making sure REGARDLESS of what value &#039category&#039 is, it automatically knows what table to send to. Meaning, I cannot tell it what table to go to like<BR>Insert X into table BLAH<BR><BR>Rather, it has to be like:<BR>dimcd<BR>dimcd=request.form("Category")= <BR>If dimcd="CD"<BR>Then insert Dimcd into TalbeCD<BR><BR>ANd so on. I hope that made sense. Your code looked right until the end, but I could be wrong. Thanks. I hope this makes sense, there are no ex&#039s like it. It&#039s odd, I am sure.<BR><BR>Have a good day. I really appreciate it.

Posting Permissions

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