p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

proasp_codeclinic thread: Problems with Select Case and Database Update


Message #1 by "Bob" <bobage24@a...> on Sun, 24 Sep 2000 07:04:56 +0100
How about doing it this way:
Change the values of the radio buttons from vCount1, vCount2 etc to just
Count1, Count2, Count3 etc

<%
strPoll = Request.Form("R1")

Select Case strPoll
Case Count1, Count2, Count3, Count4

    strSQL = "UPDATE Poll "
    strSQL = strSQL & "SET " & strPoll & " = " & strPoll & " + 1"

    Set objConn = Server.CreateObject("ADODB.Connection")
    objConn.Open strConnect
    objConn.execute(strSQL)
    objConn.close
    Set objConn = nothing

Case Else
    Response.Write( _
        "An error occured. Something did not match<br>" & vbCrLf & _
        "The value of strPoll is " & strPoll)
End Select
%>

Cheers
Ken




----- Original Message -----
From: "Bob" <bobage24@a...>
To: "Code Clinic" <proasp_codeclinic@p...>
Sent: Sunday, September 24, 2000 4:04 PM
Subject: [proasp_codeclinic] Problems with Select Case and Database Update


> Hello,
> I am trying to create a simple poll program. I am trying to use select
> case to grab the info from my radio buttons, but I cannot get it to work.
> Here is the code I am using:
> <% OPTION EXPLICIT %>
> <!--#include file="Connection.asp"-->
>
> <%
> Dim rsPoll, varPoll
> Dim SQL
> SQL = "SELECT Count1, Count2, Count3, Count4 "
> SQL = SQL & "FROM Poll "
>
> Set rsPoll = Server.CreateObject("ADODB.Recordset")
> rsPoll.Open SQL, objConn, adOpenForwardOnly, adLockOptimistic, adCmdText
>
> varPoll = Request.Form("R1")
> Select Case varPoll
> Case "vCount1"    rsPoll("Count1") = rsPoll("Count1")+1
> Case "vCount2"    rsPoll("Count2") = rsPoll("Count2")+1
> Case "vCount3"    rsPoll("Count3") = rsPoll("Count3")+1
> Case "vCount4"    rsPoll("Count4") = rsPoll("Count4")+1
> End Select
> rsPoll.Update
> rsPoll.Close
> set rsPoll = nothing
>
>  Response.Redirect "Results.asp"
> %>
>  Any help would be greatly appreciated,
> bob



  Return to Index