+ Reply to Thread
Results 1 to 8 of 8
  1. #1
    Member
    Join Date
    Jun 2001
    Posts
    56

    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?

  2. #2
    Member
    Join Date
    Jan 2000
    Posts
    49
    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

  3. #3
    Member
    Join Date
    Jun 2001
    Posts
    56
    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?

  4. #4
    Banned qball's Avatar
    Join Date
    Oct 1999
    Location
    Rockaway, NJ 07866
    Posts
    1,730
    you're welcome.

  5. #5
    Banned qball's Avatar
    Join Date
    Oct 1999
    Location
    Rockaway, NJ 07866
    Posts
    1,730
    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.

  6. #6
    Member vass0922's Avatar
    Join Date
    Feb 2000
    Location
    Centreville, VA US
    Posts
    385
    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).]

  7. #7
    Member
    Join Date
    Apr 2000
    Location
    Alberta, Canada
    Posts
    125
    ...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!

  8. #8
    Member
    Join Date
    Jan 2001
    Location
    Bellevue, WA
    Posts
    78
    You set the session timeout by using the Session.Expires function. IE:

    <%Session.Expires("5")%>

    Would make the session timeout after 5 minutes.
    -Digital D.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts







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