Re: redirect if record already exists in database

From: Jim in Arizona (tiltowait_at_hotmail.com)
Date: 01/06/05


Date: Thu, 6 Jan 2005 08:40:16 -0700

I'm using an access 2K database.

I'm trying to do what you suggested but I'm running into some trouble. I'm
getting this error:

a.. Error Type:
Microsoft VBScript runtime (0x800A01A8)
Object required: 'SELECT * from voting'
/castvote.asp, line 17

Here's my code:

------------------------- castvote.asp-----------------------------

Dim empname, Conn, SQL1

empname = Request.ServerVariables("AUTH_USER")

Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
server.mappath("eoty.mdb")

SQL1 = "SELECT * from votingemp where(voter = '" & empname & "')"

Conn.Execute SQL1,,129

'Response.Write(SQL1)

Response.Write(SQL1.Fields("voter"))

-------------------------------- end asp -----------------------------

When I comment out the Response.Write(SQL1.Fields("voter")) and uncomment
the Response.Write(SQL1), I get this SQL Statement:

SELECT * from votingemp where(voter = 'DOMAIN\jim')

I tested that statement in access and it worked fine.

Line 17 is Response.Write(SQL1.Fields("voter"))

My plan, if this was working, was to place the result of the
Response.Write(SQL1.Fields("voter")) into a variable like so:

testvariable = Response.Write(SQL1.Fields("voter"))

Then do some branching off of that like so:

If testvariable = empname Then
Response.Write("You already voted")
Else
VoteDB Insert string Here
End If

Am I heading in the right direction?

Thanks,
Jim

"Jeff Cochran" <jeff.nospam@zina.com> wrote in message
news:41dc9a6c.338306699@msnews.microsoft.com...
> On Wed, 5 Jan 2005 13:59:28 -0700, "Jim in Arizona"
> <tiltowait@hotmail.com> wrote:
>
>>I'm wanting to do a simple controlled voting page. I too our webserver off
>>anonymous and everyone who accesses the website is a domain authenticated
>>user. I've already done some control structure pages based on
>>Request.ServerVariables("AUTH_USER"), which works great. That's also how I
>>would do this page, in my basic thinking.
>>
>>My idea is to have an access database with two tables. One table will have
>>the vote written to it and the other table will have the AUTH_USER written
>>to it when the employee casts their vote. I'm wondering how I would do a
>>test against that table to see if their name has already been written to
>>the
>>table. So, if an employee votes already, when they go to vote again, their
>>user logon would be tested against all entries in the table and if it
>>exists, the vote would not be written and they would be redirected to
>>another page that politely tells them they've already voted.
>>
>>I'm hoping there is an easy answer for this. :)
>
> Do a SELECT from the authorization table WHERE the user column is
> equal to AUTH_USER, then branch on whether it's null. Or just us an
> IF EXISTS in your query if your database supports that and do the
> entire thing in a single query. Books Online has examples if you use
> SQL Server.
>
> Jeff



Relevant Pages

  • mysql and mythtv
    ... could not connect to the database". ... 2005-11-23 13:48:51.441 No error type from QSqlError? ... Strange... ...
    (alt.os.linux.suse)
  • Re: [PHP] Pragmatically changing a "Record Number"
    ... The ID key field of a record should not have any explicit meaning. ... already off-topic for PHP, but they should have told you on the MySQL ... mistake can make a pig's breakfast of your entire database. ... One vote per day per email limit. ...
    (php.general)
  • Re: A Parable of Two Carpenters
    ... > wore interessted in politics would bother to vote. ... Put all public information in an ordered, searchable database. ... Money can be routet back to the account of the patient ... And, thus, you get more people involved in "local politics" by simply ...
    (alt.lang.asm)
  • Message from Hell in OE 5.0.6
    ... Outlook Express for Mac, version 5.0.6. ... OE crashes with an Error Type 1. ... I walked him through rebuilding the database and ...
    (microsoft.public.internet.outlookexpress.mac)
  • Message from Hell in OE 5.0.6
    ... Outlook Express for Mac, version 5.0.6. ... OE crashes with an Error Type 1. ... I walked him through rebuilding the database and ...
    (microsoft.public.internet.outlookexpress.mac)