日期:2011-01-04  浏览次数:20930 次

1. vote.asp

<%@ LANGUAGE="VBSCRIPT"%>
<%OPTION EXPLICIT%>
<%Response.Buffer = True%>

<!-- #INCLUDE FILE="adovbs.inc" -->

<%
'*** Remember to create those variables before trying to use them.

    Dim objConn    
    Dim objRec3
    Dim strConnect
    Dim    varTopic, varTopicID, varSelectionNum, varSelected
    Dim i, varTotal, varThis, varThisTitle, varAlreadyVote

    strConnect = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath("vote.mdb") & ";DefaultDir=" & Server.MapPath(".") & ";DriverId=25;FILE=MS Access;MaxBufferSize=512;PageTimeout=5;SafeTransactions=0;Threads=3;UID=admin;UserCommitSync=Yes;;User Id=admin;"
    
    Set objConn = Server.CreateObject ("ADODB.Connection")     '*** Create an ADO database connection object.
    Set objRec3 = Server.CreateObject ("ADODB.Recordset")     '** Create an ADO RecordSet object.
    
    objConn.Open strConnect    '*** Open the connection to the database
    objRec3.Open "vote", objConn, adOpenForwardOnly, adLockPessimistic, adUseServer '*** Open the recordset

    varTopic = Request.Form("topic")
    varTopicID = Request.Form("topicID")
    if varTopicID="" then
        varTopicID = Request.QueryString("topicID")
    end if
    varSelectionNum = Request.Form("selectionNum")
    varSelected = Request.Form("selected")

    objRec3.Filter = 0
    objRec3.Filter = "topicID=" & varTopicID    'only number can be filter?
    
    If NOT objRec3.EOF then
        if Request.Form("selected") = "" then
        else
            varAlreadyVote="alreadyVote" & "_" & varTopicID
            if Session(varAlreadyVote)<>"true" then
                objRec3("selection" & varSelected & "_count") = objRec3("selection" & varSelected & "_count") +1
                objRec3.Update
                Session(varAlreadyVote)="true"
            end if
        end if
        varTotal=0
        for i=0 to objRec3("selectionNum")-1
            varTotal=varTotal+ objRec3("selection" & i & "_count")
        next
%>

<p align=left>    <% =varTopic %> </p>
<p align=center>
<table width=480 border=0 cellspacing=0 cellpadding=0 bgcolor=#000000>
<caption align=left><font size=2>共有 <font color=red><% =varTotal %></font>人参加</font></caption>
<tr><td>
<table width=480 border=0 c