By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,186 Members | 1,620 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,186 IT Pros & Developers. It's quick & easy.

HELP!! dynamic querystring, dynamic input fields

P: 2
Dear all,

I have a form with dynamically created input fields. These fields go to next page for submitting into SQL database. The thing is all fields are the same but 4 fields. So each record must be submitted with a unique key, while everything is the same, these 4 fields must be different....

Idealy, these are the codes. please teach me how to do it.

Expand|Select|Wrap|Line Numbers
  1.  
  2. objConn.Open(sConnection) 
  3.  
  4. sRowNum = request.querystring("row_num")
  5.  
  6. While sRowNum > 0 
  7.  
  8. sDefectCode = request.querystring("defect_code[sRowNum]")
  9. sDefect_descr = request.querystring("defect_descr[sRowNum]")
  10. sPart_num = request.querystring("part_num[sRowNum]")
  11. sPart_qty = request.querystring("part_qty[sRowNum]")
  12.  
  13.  
  14. strInsertSql = "insert into table1"
  15. strInsertSql = strInsertSql& "(the_key, org_num,dealer_name,dealer_phone,reg_date,submit_name,cus_firstname,cus_lastname,cus_phone,cus_street_address,cus_post_code,cus_city,cus_country,cus_person_num,which_machine,which_model,vin_num,machine_reg_num,purchase_date,defect_code,part_num,part_qty,descr,comm,mileage,labor_hr,claim_date) values("
  16. strInsertSql = strInsertSql& "'"& request.querystring("the_key")&"',"
  17. strInsertSql = strInsertSql& "'"& request.querystring("org_num")&"',"
  18. strInsertSql = strInsertSql& "'"& request.querystring("dealer_name")&"',"
  19. strInsertSql = strInsertSql& "'"& request.querystring("dealer_phone")&"',"
  20. strInsertSql = strInsertSql& "'"& request.querystring("reg_date")&"',"
  21. strInsertSql = strInsertSql& "'"& request.querystring("submit_name")&"',"
  22. strInsertSql = strInsertSql& "'"& request.querystring("cus_firstname")&"',"
  23. strInsertSql = strInsertSql& "'"& request.querystring("cus_lastname")&"',"
  24. strInsertSql = strInsertSql& "'"& request.querystring("cus_phone")&"',"
  25. strInsertSql = strInsertSql& "'"& request.querystring("cus_street_address")&"',"
  26. strInsertSql = strInsertSql& "'"& request.querystring("cus_post_code")&"',"
  27. strInsertSql = strInsertSql& "'"& request.querystring("cus_city")&"',"
  28. strInsertSql = strInsertSql& "'"& request.querystring("cus_country")&"',"
  29. strInsertSql = strInsertSql& "'"& request.querystring("cus_person_num")&"',"
  30. strInsertSql = strInsertSql& "'"& request.querystring("which_machine")&"',"
  31. strInsertSql = strInsertSql& "'"& request.querystring("which_model")&"',"
  32. strInsertSql = strInsertSql& "'"& request.querystring("vin_num")&"',"
  33. strInsertSql = strInsertSql& "'"& request.querystring("reg_num")&"',"
  34. strInsertSql = strInsertSql& "'"& request.querystring("purchase_date")&"',"
  35. strInsertSql = strInsertSql& "'sDefectCode',"
  36. strInsertSql = strInsertSql& "'sPart_num',"
  37. strInsertSql = strInsertSql& "'sPart_qty',"
  38. strInsertSql = strInsertSql& "'sDefect_descr',"
  39. strInsertSql = strInsertSql& "'"& request.querystring("comm")&"',"
  40. strInsertSql = strInsertSql& "'"& request.querystring("mileage")&"',"
  41. strInsertSql = strInsertSql& "'"& request.querystring("labor_hr")&"',"
  42. strInsertSql = strInsertSql& "'"& request.querystring("claim_date")&"'"
  43. strInsertSql = strInsertSql&")"
  44.  
  45. objConn.Execute(strInsertSql)
  46.  
  47. sThe_key = sThe_Key + 1
  48. sRowNum = sRowNum - 1
  49.  
  50. wend
  51.  
Jul 25 '08 #1
Share this Question
Share on Google+
3 Replies


omerbutt
100+
P: 638
sorry but ciould not get you what youwant the record you are inserting here is insilde a while loop and of course they will have a unique key but after they are inserted and sql will do it automatically if you have the primary key in it
sorry if i got you wrong ....then
and yes your these lines
Expand|Select|Wrap|Line Numbers
  1. strInsertSql = "insert into table1"
  2. strInsertSql = strInsertSql& "(the_key, 
  3.  
that "the_key" i think that is the primary key i was talking about you donot need to assign it any value it will be givn automatically by the databases if and only if you have made that PRIMARYKEY ;)
regards ,
Omer Aslam
Jul 27 '08 #2

jhardman
Expert 2.5K+
P: 3,405
I often do something like this when I make the dynamic inputs:
Expand|Select|Wrap|Line Numbers
  1. for x = 0 to 4 %>
  2.    <input type="text" name="dynamicTextInput<%=x%>">
  3. <%
  4. next
then when I pull it up on the form handler:
Expand|Select|Wrap|Line Numbers
  1. for x = 0 to 4
  2.    if request.form("dynamicTextInput"&x) <> "" then
  3.       'insert record into the db
  4.    end if
  5. next
Let me know if this helps.

Jared
Jul 28 '08 #3

P: 2
Jared,

You are awesome!! Thanks! worked like a charm.

Ken

I often do something like this when I make the dynamic inputs:
Expand|Select|Wrap|Line Numbers
  1. for x = 0 to 4 %>
  2.    <input type="text" name="dynamicTextInput<%=x%>">
  3. <%
  4. next
then when I pull it up on the form handler:
Expand|Select|Wrap|Line Numbers
  1. for x = 0 to 4
  2.    if request.form("dynamicTextInput"&x) <> "" then
  3.       'insert record into the db
  4.    end if
  5. next
Let me know if this helps.

Jared
Jul 28 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.