Wrox Programmer Forums
Access ASP Using ASP with Microsoft Access databases. For Access questions not specific to ASP, please use the Access forum. For more ASP forums, please see the ASP forum category.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access ASP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old May 21st, 2004, 06:49 AM
Friend of Wrox
Join Date: May 2004
Posts: 105
Thanks: 0
Thanked 0 Times in 0 Posts
Default Avoid duplicates error screen


I want to avoid the error page when a record is already entered in the table. I`m going to be more specific...

I `ve got a table called "Table" and the primary key is contains two fields ("Unique_id" and "Name"). This mean that every user owns a Unique_id and is able to insert many records only if he types a different name each time! (I`m saying all these so that I can be more understoodable)
When ever a user tries to insert a "name" for a second time an error screen appears (The page cannot be displayed)...
So I would like a script so that on insert or on update it would check for a duplicate...

                              Thank you in advance!
Old August 3rd, 2004, 05:47 AM
Friend of Wrox
Join Date: Oct 2003
Posts: 479
Thanks: 0
Thanked 3 Times in 3 Posts
Send a message via MSN to surendran Send a message via Yahoo to surendran

set Rs1=server.CreateObject ("ADODB.Recordset")
sql="Select Name from Table where Name ='" &txtname& "'"
Rs1.Open sql,Conn ,1,3
if Rs1.RecordCount=1 then
msg="User Already exist"
end if

(Anything is Possible)
Old August 3rd, 2004, 08:58 AM
Friend of Wrox
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post

Hi there,

Probably you will have to check for Unique_Id too, as far as I understand this, it can have different names for single Unique_Id. If that is right, then your query should look something like this.
sql = "Select Name from Table where Unique_Id = " & UniqueId_Var & " and Name ='" &txtname& "'"
Else it will not let you add "xyz" as NAME again for another Unique_Id.

Hope that helps.

- Vijay G
Strive for Perfection

Similar Threads
Thread Thread Starter Forum Replies Last Post
Handling the no duplicates index error Enoch Access 18 April 7th, 2006 07:07 AM
how to avoid access denied error satyakishore Javascript 1 March 29th, 2006 01:48 PM
Set Permissions correctly to avoid 80070005 error shogunmike Classic ASP Basics 11 October 25th, 2005 06:50 PM
Automization of screen shots of error pages from c aravwind General .NET 1 July 19th, 2004 09:30 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.