Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 7th, 2008, 08:03 AM
Registered User
 
Join Date: Mar 2008
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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 appended.
in the database i have these field, question, option1,option2,option1_ctr,option2_ctr.
if option1 is clicked, then option1_ctr should be incremented.

<%
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.CreateObject("ADODB.Connection")

Conn.ConnectionString = "DSN=pollz"
Conn.Open


mySQL = "SELECT * FROM pollz"


Set RS = Server.CreateObject("ADODB.Recordset")
RS.Open mySQL, Conn
rs.movefirst
clr=1
ques=rs("question")
session("ques")=ques
yes_ctr=rs("option1_ctr")
no_ctr=rs("option2_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="JavaScript">

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

       if (form.ans[0].checked)
           {
        y_ctr=y_ctr+1;
        document.array.hid_code_y.value=y_ctr;
         document.array.hid_code_n.value=n_ctr;

        }
       else
       {
       n_ctr=n_ctr+1;
       document.array.hid_code_n.value=n_ctr;
        document.array.hid_code_y.value=y_ctr;
           }

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

<body>

<%
response.write"<form name='array' method='post' action='post.asp'>"

response.write"<table valign='top' border=1 align=center width='80%' cellpadding=0 cellspacing=0>"
response.write"<tr><td width='70%'>" & ques & "</td>"



response.write"<td width='6%'><input type='radio' onClick='testButton(this.form)' name='ans'>" & rs("option1") & "</td>"
response.write"<td width='6%'><input type='radio' onClick='testButton(this.form)' name='ans'>" & rs("option2") & "</td>"

clr=clr+1



response.write "</table>"
response.write "<input type='hidden' name='hid_code_y'>"
response.write "<input type='hidden' name='hid_code_n'>"
response.write"</form>"


y_ctr=request.Form("hid_code_y")
n_ctr=request.Form("hid_code_n")


execSQL="update pollz set option1_ctr=" & y_ctr & ",option2_ctr=" & n_ctr &" where question=" & session("ques")
response.write execSQL
'Conn.execute(execSQL)
RS.Close
Set RS = Nothing
Set Conn = Nothing

%>


</body>
</html>






Similar Threads
Thread Thread Starter Forum Replies Last Post
too few parameters expected 1 jim11 Access VBA 1 December 7th, 2005 03:41 PM
Too few parameters. 1 expected !!! chacquard Access VBA 2 June 21st, 2005 08:00 AM
too few parameters expected n desprate Access VBA 6 April 29th, 2005 06:33 AM
Error "Too Few Parameters - Expected 1" timmaher Access VBA 2 August 31st, 2004 04:04 AM
Too few parameters. Expected 1. harry_barry Classic ASP Databases 2 May 26th, 2004 04:12 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.