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

update stt- Too few parameters. Expected 1.

P: 7
let me tell u what the code deos:
retrieve data ( text box, 2 radio buttons, ) from db.
on selection of any of the radio buttons, the counter should be incremented accordinglt
in the database i have these fields, question, option1,option2,option1_ctr,option2_ctr.
if option1 is clicked, then option1_ctr should be incremented. similarly
if option2 is clicked, then option2_ctr should be incremented.
Expand|Select|Wrap|Line Numbers
  1. <%
  2. Dim Conn         'Holds the Database Connection Object
  3. Dim RS          'Holds the recordset for the records in the database
  4. Dim mySQL         'Holds the SQL query to query the database 
  5. Dim execSQL 
  6. Dim ques
  7. Dim opt1
  8. Dim opt2
  9. Dim y_ctr
  10. Dim n_ctr
  11. Dim theform 
  12.  
  13.  
  14. Set Conn = Server.CreateObject("ADODB.Connection")
  15.  
  16. Conn.ConnectionString = "DSN=pollz"
  17. Conn.Open
  18.  
  19.  
  20. mySQL = "SELECT * FROM pollz"
  21.  
  22.  
  23. Set RS = Server.CreateObject("ADODB.Recordset")
  24. RS.Open mySQL, Conn
  25. rs.movefirst 
  26. clr=1
  27. 'ques=rs("question")
  28. 'session("ques")=ques
  29. yes_ctr=rs("option1_ctr")
  30. no_ctr=rs("option2_ctr")
  31. opt1= rs("option1")
  32. opt2 =rs("option2")
  33. response.write "yes" & yes_ctr
  34. response.write "no" & no_ctr
  35. %>
  36. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  37. <html>
  38. <head>
  39. <SCRIPT language="JavaScript">
  40.  
  41. function testButton (form){
  42. var y_ctr;
  43. var n_ctr;
  44. var quest;
  45. y_ctr = <% =yes_ctr %>
  46. n_ctr = <% =no_ctr %>
  47. alert(y_ctr)
  48. alert(n_ctr)
  49.  
  50.  
  51.        if (form.ans[0].checked)
  52.            {
  53.         alert("inside")
  54.         y_ctr=y_ctr+1;
  55.         document.array1.hid_code_y.value=y_ctr;
  56.          document.array1.hid_code_n.value=n_ctr;
  57.  
  58.         }
  59.        else
  60.        {
  61.        n_ctr=n_ctr+1;
  62.        document.array1.hid_code_n.value=n_ctr;
  63.        document.array1.hid_code_y.value=y_ctr;
  64.            }
  65.  
  66. document.array1.submit();
  67. }
  68. </script>
  69. </head>
  70.  
  71. <body>
  72.  
  73. <form name='array1' method='post' action='post.asp'>
  74.  
  75. <table valign='top' border=1 align=center width='80%' cellpadding=0 cellspacing=0>
  76. <tr><td width='70%'> <%= rs("question") %></td>
  77. <td width='6%'><input type='radio' onClick='testButton(this.form)' name='ans' value= <%=rs("option1") %>> <%=rs("option1") %></td>
  78. <td width='6%'><input type='radio' onClick='testButton(this.form)' name='ans' value= <%=rs("option2") %>> <%=rs("option2") %></td>
  79. </table>
  80. <input type='hidden' name='hid_code_y'>
  81. <input type='hidden' name='hid_code_n'> 
  82. <input type='hidden' name='quess' value= <%= rs("question")%>>
  83. </form>
  84. <%
  85. y_ctr=request.Form("hid_code_y")
  86. n_ctr=request.Form("hid_code_n")
  87. quest=request.Form("quess")
  88. session("ques")=quest
  89. response.write quest
  90.  
  91. ty=rs(1)
  92. response.write ty
  93. execSQL="update pollz set option1_ctr=" & y_ctr & ",option2_ctr=" & n_ctr & " where question=" & ty
  94.  
  95. response.write execSQL
  96. Conn.execute(execSQL)
  97. RS.Close
  98. Set RS = Nothing
  99. Set Conn = Nothing
  100.  
  101. %>
  102.  
  103.  
  104. </body>
  105. </html>
Mar 8 '08 #1
Share this Question
Share on Google+
1 Reply


jhardman
Expert 2.5K+
P: 3,405
so... Do you have a question?

Jared
Mar 18 '08 #2

Post your reply

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