Print Page | Close Window

Checking to see if someone has voted

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=3956
Printed Date: 30 March 2026 at 3:26am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Checking to see if someone has voted
Posted By: choshour
Subject: Checking to see if someone has voted
Date Posted: 30 June 2003 at 9:05am

<!--#include file="..\forum/common.asp" -->
<!--#include file="check_permission.asp" -->

<%

'Dimension variables
Dim Conn    'Holds the Database Connection Object
'Dim strSQL   'Holds the SQL query for the database


'Create an ADO connection odject
Set Conn = Server.CreateObject("ADODB.Connection")

'Set an active connection to the Connection object using a DSN-less connection
Conn.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("?????.mdb")
%>
<!--#include file="check_voted.asp" -->

 

Here is the include file:

<%
Dim rsVoted
Dim SQL

set rsVoted = Server.CreateObject("ADODB.Connection")

SQL= "SELECT COUNT(*) FROM ratings WHERE UserName='" & strLoggedInUsername & "'"

rsVoted.Open SQL, conn

IF rsVoted.Fields(0).Value <> 0 then
Response.Redirect "
http://www.p-15.com/team_ratings/voted.asp - http://www.p-15.com/team_ratings/voted.asp "
END IF

rsVoted.close
set rsVoted = nothing
%>

I get this error

Microsoft OLE DB Provider for ODBC Drivers error '80040e4e'

Operation was canceled.

/Team_Ratings/check_voted.asp, line 9

 

Any ideas I am trying to check and see if this user had vote in the poll already.  We you vote I store the username with it.  I want to check and see if the username is in the database.  If so then redirect them to another page.

Hope someone can help me.




Replies:
Posted By: MorningZ
Date Posted: 30 June 2003 at 11:19am

<%
Dim rsVoted
Dim SQL

set rsVoted = Server.CreateObject("ADODB.RecordSet")

SQL= "SELECT COUNT(*) FROM ratings WHERE UserName='" & strLoggedInUsername & "'"

rsVoted.Open SQL, conn

IF rsVoted.Fields(0).Value <> 0 then
Response.Redirect "
http://www.p-15.com/team_ratings/voted.asp - http://www.p-15.com/team_ratings/voted.asp "
END IF

rsVoted.close
set rsVoted = nothing
%>



-------------
Contribute to the working anarchy we fondly call the Internet


Posted By: pmormr
Date Posted: 30 June 2003 at 12:06pm

nice spot morningz! I missed that one



-------------
Paul A Morgan

http://www.pmorganphoto.com/" rel="nofollow - http://www.pmorganphoto.com/


Posted By: choshour
Date Posted: 30 June 2003 at 2:40pm
Thanks a lot that explains it.  I ended up going back and starting the code for that page over and got it working.  I still did not know what was different.  Now that you pointed it out it obvious.  Thanks again.  This makes code so much easier when you have more than one set of eyes looking at a problem



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net