update stt- Too few parameters. Expected 1.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sank06
    New Member
    • Dec 2006
    • 7

    update stt- Too few parameters. Expected 1.

    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,op tion2_ctr.
    if option1 is clicked, then option1_ctr should be incremented. similarly
    if option2 is clicked, then option2_ctr should be incremented.
    [code=asp]<%
    Dim Conn 'Holds the Database Connection Object
    Dim RS 'Holds the recordset for the records in the database
    Dim mySQL 'Holds the SQL query to query the database
    Dim execSQL
    Dim ques
    Dim opt1
    Dim opt2
    Dim y_ctr
    Dim n_ctr
    Dim theform


    Set Conn = Server.CreateOb ject("ADODB.Con nection")

    Conn.Connection String = "DSN=pollz"
    Conn.Open


    mySQL = "SELECT * FROM pollz"


    Set RS = Server.CreateOb ject("ADODB.Rec ordset")
    RS.Open mySQL, Conn
    rs.movefirst
    clr=1
    'ques=rs("quest ion")
    'session("ques" )=ques
    yes_ctr=rs("opt ion1_ctr")
    no_ctr=rs("opti on2_ctr")
    opt1= rs("option1")
    opt2 =rs("option2")
    response.write "yes" & yes_ctr
    response.write "no" & no_ctr
    %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <SCRIPT language="JavaS cript">

    function testButton (form){
    var y_ctr;
    var n_ctr;
    var quest;
    y_ctr = <% =yes_ctr %>
    n_ctr = <% =no_ctr %>
    alert(y_ctr)
    alert(n_ctr)


    if (form.ans[0].checked)
    {
    alert("inside")
    y_ctr=y_ctr+1;
    document.array1 .hid_code_y.val ue=y_ctr;
    document.array1 .hid_code_n.val ue=n_ctr;

    }
    else
    {
    n_ctr=n_ctr+1;
    document.array1 .hid_code_n.val ue=n_ctr;
    document.array1 .hid_code_y.val ue=y_ctr;
    }

    document.array1 .submit();
    }
    </script>
    </head>

    <body>

    <form name='array1' method='post' action='post.as p'>

    <table valign='top' border=1 align=center width='80%' cellpadding=0 cellspacing=0>
    <tr><td width='70%'> <%= rs("question") %></td>
    <td width='6%'><inp ut type='radio' onClick='testBu tton(this.form) ' name='ans' value= <%=rs("option1" ) %>> <%=rs("option1" ) %></td>
    <td width='6%'><inp ut type='radio' onClick='testBu tton(this.form) ' name='ans' value= <%=rs("option2" ) %>> <%=rs("option2" ) %></td>
    </table>
    <input type='hidden' name='hid_code_ y'>
    <input type='hidden' name='hid_code_ n'>
    <input type='hidden' name='quess' value= <%= rs("question")% >>
    </form>
    <%
    y_ctr=request.F orm("hid_code_y ")
    n_ctr=request.F orm("hid_code_n ")
    quest=request.F orm("quess")
    session("ques") =quest
    response.write quest

    ty=rs(1)
    response.write ty
    execSQL="update pollz set option1_ctr=" & y_ctr & ",option2_c tr=" & n_ctr & " where question=" & ty

    response.write execSQL
    Conn.execute(ex ecSQL)
    RS.Close
    Set RS = Nothing
    Set Conn = Nothing

    %>


    </body>
    </html>[/code]
    Last edited by jhardman; Mar 18 '08, 09:26 PM. Reason: put code in code tags. Please note button marked - #
  • jhardman
    Recognized Expert Specialist
    • Jan 2007
    • 3405

    #2
    so... Do you have a question?

    Jared

    Comment

    Working...