ip compare DB field loginIP to REMOTEadr

I have a from that a visitor completes. It saves the form in an access db with current date (date format) as dateadded and Request.ServerVariables("REMOTE_ADDR") as loginIP (textfield). There a a couple of field saved but the are not important at this time.
Once the visitor completes the form they can not resubmit another form until the next day. So if a visitor tries to submit a second form on the same day they are sent to a "too bad fo you you have to wait until tomorrow" page.

I query the table  where the dateadded equal date() and loginIP=Request.ServerVariables("REMOTE_ADDR") Right now I can get the new ip from the second attempt to submit another form and I can response.write both the dateadded and the loginIP but when i query it nothing happens. I have looked all over the web for a solution but i can't find a solution or a part solution I can expand on. I ahve attached the code I am having a problem with.newtest.txt
DDeanAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dave BaldwinFixer of ProblemsCommented:
I used a simpler page to test this.  I had to change the SQL string to put '#' around the date and single quotes around the IP address text.
SQL = "SELECT * FROM Contestvotes where dateadded = #" & finaldate & "# and LoginIP = '" & NewIP & "'"

Open in new window

0
DDeanAuthor Commented:
Dave,it still isn't selecting base on the where. Could it be possible may structure is wrong

there 3 fields
dateadded - type: date/time short date added as default
selection - type: text length 50
loginIP - Type: text length 15 123.456.789.012 ( the length was 14. fixed ... that still no work

here is the code that I last tried

If I don't select 'where' I can list all the fields including the calculated fields

5/7/20155/10/201564.114.228.241
5/7/20155/10/201564.114.228.241
5/4/20155/10/201564.114.228.241
5/3/20155/10/201564.114.228.241
5/2/20155/10/201564.114.228.241
5/8/20155/10/201564.180.179.174
5/10/20155/10/201564.114.228.241
5/8/20155/10/201564.114.229.185

I am beginning to feel rather stupid. In my mind the code should work
Thoughts???
0
DDeanAuthor Commented:
Forgot the code
newtest.txt
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Dave BaldwinFixer of ProblemsCommented:
Attached is the code I used for testing along with all the sections I commented out.
NewIP.txt
0
DDeanAuthor Commented:
it does the 'Response.Write("final date2:  " & finaldate2 & "  this is new IP:  "&NewIP) '

and I was getting tat as well.. but it doesn't do 'SQLstr = "SELECT * FROM Contestvotes where dateadded = #" & finaldate & "# and LoginIP = '" & NewIP & "'" '

nothing happens I get the response write at the top but the compare selection in the do while and the response at the bottom do nothing as if the 'do while' isn't finding anything.
0
Dave BaldwinFixer of ProblemsCommented:
Don't know what to tell you.  It's works exactly as described here.  I would have to add entries for it to find anything for today.  'today' is the date it is comparing it to.  Your code won't find anything else as it is written.
0
DDeanAuthor Commented:
date records I have been using:

Table: Contestvotes

dateadded      selection          loginIP
5/8/2015            2                 64.180.179.174
5/10/2015          1                 64.114.228.241
5/10/2015          2                 64.114.229.185

structure:

dateadded      Date/Time
selection         Text(50)
loginIP             Text(15)

It in theory it should only find the second record ... the ip listed is my IP so I should get the 'sorry you can't vote again until tomorrow'

All I want is to prevent someone from adding a second vote until the next day. If there is a better way to do this, I am all ears. To me, my code seemed to be simple logical way to achieve this .. but apparently not  
 : (
0
Dave BaldwinFixer of ProblemsCommented:
It's a weird one. Apparently ASP VBscript is still aware of the 'date' format when you do the comparison.  When I used 'Cstr' to convert it, then it works.  Updated code attached.
NewIP.txt
0
DDeanAuthor Commented:
we are half waythere. the 'sorry' displays but when I changed the last day I voted to 5/8/2015 I should get the contest message but is goes to the 'sorry' message.  

I tried changing the sql to
SQLstr = "SELECT * FROM Contestvotes where dateadded < #" & finaldate & "# and LoginIP = '" & NewIP & "'"

And all I got was a blank page ...
0
Dave BaldwinFixer of ProblemsCommented:
That version with '<' is doing a string comparison, not really a date comparison.
0
Dave BaldwinFixer of ProblemsCommented:
I just checked from another computer which also is in that database... and the obvious occurred to me.  The SQL statement selects Only those records with the current date and IP address... so it will Never show the contest message the way it is written.  If I change it to...
SQLstr = "SELECT * FROM Contestvotes where LoginIP = '" & NewIP & "'"

Open in new window

then it will find all of the entries for that IP address and if none are for today's date, then the 'contest' message will show.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
DDeanAuthor Commented:
I think you did it !!! I will try this in the morning ... my brain is FULL
0
DDeanAuthor Commented:
But it looks like it worked !! I truly can't thank you enough!! Happy Happy
0
DDeanAuthor Commented:
Like I said ... Happy Happy !!!
0
Dave BaldwinFixer of ProblemsCommented:
A further addition because you want the most recent entry first...
SQLstr = "SELECT * FROM Contestvotes where LoginIP = '" & NewIP & "' ORDER BY dateadded DESC""

Open in new window

0
Dave BaldwinFixer of ProblemsCommented:
You're welcome, glad to help.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.