-
Can this be done in Access?
I need to store the number of votes a specific user receives on Microsoft Access. I want this to be on a single record like this:
Username 26
How can this be done in access so that each time someone votes through an ASP page, the number of votes in that record is added to the new vote submitted?
-
Hi,
You've been very brief in your post and I'm not sure if I understand you right but here goes.
When the ASP page is submitted, check to see if that username exists, if not create a record for that username and add 1 to the 'count' field. If the user exists, fetch the value in the 'count' field, add 1 to it and write it back to that record. I presume that you are doing this with SQL statements.
Let me know if I've got the wrong end of the stick or need more info.
LostUser
-
Thanks for your help. My explanation was very brief. Here's what I want again : I'm going to have a rating drop-down menu which visitors will use to rate a site with any number from 1 to 10. This number is going to the database to be included in the number of votes field received by that particular site. I might also need someway of computing the average rate for each site. But here's what the database fields might look like:
site name----votes---#times
where votes is the field that will increase each time someone places a new vote and #times is the number of times someone has voted for the site which will change too.
How can this be done without creating a new record every time someone places a vote for a specific site?
-
Banned
-
Banned
short answer, yes.
long answer. First make two columns in Access table, username and numvotes (name 'em whatever you want). Putting them in one string is problematic as you would need to parse username/votes, increment votes and concat username/votes. Putting them in one string defeats purpose of Access, so just use a text file. So use two columns, makes life easier.
Then what you want can be accomplished many ways. One follows.
ASP has that darn session concept, use it. Store username when user accesses site in a session var.
Then when user votes, you then execute SQL like this:
UPDATE tablename SET numvotes = numvotes + 1 WHERE username=sessionVarUserName;
Post back with any questions.
-
Member
What you could do is, have a user table, and a site table, and a vote table.
SiteTable
SiteId
SiteName
UserTable
userId
UserName
VoteTable
SiteId
UserId
UniqueVotes
TotalVotes
//only update unique votes for unique visitors
UPDATE Votes
SET UniqueVotes = 1
WHERE UserID NOT IN (SELECT UserId
FROM UserTable)
WHERE Username = 'Name')
AND SiteID = (SELECT SiteId
FROM SiteTable
WHERE SiteName = 'SiteName')
// make sure you update the total votes each time irregardless
UPDATE Votes
SET TotalVotes = 1
WHERE SiteID = (SELECT SiteId
FROM SiteTable
WHERE SiteName = 'SiteName')
theres some logic missing, such as inserting users/sites but you get the point
Keeps it "normal" 
(whoops missed a minor step )
[This message has been edited by vass0922 (edited 09-12-2001).]
-
...to go with qball's idea of using sessions, just don't forget that the client's session can timeout. If memory serves me correctly, the default session timeout is 20 minutes. (please correct me if I'm off a little) It can be changed also, but I can't remember if it's a server setting in IIS or an ASP setting that you code.(something leads me to believe it's in ASP ...but it's been awhile since I played with any ASP!)
but 20 minutes is a decent amount of time anyways!
good luck!
ciao!
-
You set the session timeout by using the Session.Expires function. IE:
<%Session.Expires("5")%>
Would make the session timeout after 5 minutes.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
New Security Features Planned for Firefox 4
Another Laptop Theft Exposes 21K Patients' Data
Oracle Hits to Road to Pitch Data Center Plans
Microsoft Preps Array of Windows Patches
Microsoft Nears IE9 Beta With Final Preview
Simplified Analytics Improve CRM, BI Tools
Android Passes RIM as Top Mobile OS in 2Q
VMware Updates Hyperic System Management
File Monitoring Key to Enterprise Security
LinkedIn Snaps Up SaaS Player mSpoke
|
Bookmarks