A voting program

zhaozj2021-02-08  218

Vote.asp

<% @ Language = "VBScript"%>

<% OPTION Explicit%>

<% Response.buffer = true%>

<%

'*** Remember to create Those Variables Before Trying to use.

DIM Objconn

DIM ObjRec3

DIM STRCONNECT

DIM VARTOPIC, VARTOPICID, VARSELECTED, 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, ADUSERVER '*** Open the Recordset

VARTOPIC = Request.form ("Topic")

VARTOPICID = Request.form ("TopiciD")

IF VARTOPICID = "" "" "

VARTOPICID = Request.QueryString ("TopicID")

END IF

VarselectionNum = Request.form ("SelectionNum")

Varselected = Request.form ("SELECTED")

ObjRec3.filter = 0

Objrec3.filter = "Topicid =" & VARTOPIPIPID 'Only Number Can Be Filter?

IF not objrec3.eof then

If Request.form ("SELECTED") = "" ""

Else

VaralReadyvote = "Alreadyvote" & "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

%>

<% = varopic%>

A total of <% = Vartotal%> people participate in

option

ratio

Number of people

<%

For i = 0 to objRec3 ("SelectionNum") - 1

Varthistitle = ObjRec3 ("Selection & I &" _title ")

VARTHIS = ObjRec3 ("Selection & I &" _COUNT ")

%>

<% = VARTHISTILE%>

Height = 12 border = 0> <% = Left (Varthis * 100 / Vartotal, 5)%>%

<% = VARTHIS%>

<%

NEXT

%>

<%

Else 'no this Topic Yet

ObjRec3.addnew

ObjRec3 ("Topicid") = Vartopicid

ObjRec3 ("Topic") = Vartopic

ObjRec3 ("SelectionNum") = vivaltencenum

For i = 0 to varselectionnum

ObjRec3 ("Selection" & I & "_Title") = Request.form ("Selection & I &" _title ")

NEXT

ObjRec3.update

Response.write "Added"

END IF

ObjRec3.close

Objconn.close

Set objRec3 = Nothing

Set objconn = Nothing

%>

2. vote.htm