Re: redirect if record already exists in database
From: Jim in Arizona (tiltowait_at_hotmail.com)
Date: 01/06/05
- Next message: Ray Costanzo [MVP]: "Re: Page Error (Can't be Found)"
- Previous message: larrybud2002_at_yahoo.com: "Re: ASP not connecting to SQL DB"
- In reply to: Jeff Cochran: "Re: redirect if record already exists in database"
- Next in thread: Chris Hohmann: "Re: redirect if record already exists in database"
- Reply: Chris Hohmann: "Re: redirect if record already exists in database"
- Messages sorted by: [ date ] [ thread ]
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
- Next message: Ray Costanzo [MVP]: "Re: Page Error (Can't be Found)"
- Previous message: larrybud2002_at_yahoo.com: "Re: ASP not connecting to SQL DB"
- In reply to: Jeff Cochran: "Re: redirect if record already exists in database"
- Next in thread: Chris Hohmann: "Re: redirect if record already exists in database"
- Reply: Chris Hohmann: "Re: redirect if record already exists in database"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|