Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases 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 9th, 2005, 03:42 PM
Friend of Wrox
 
Join Date: May 2005
Posts: 149
Thanks: 0
Thanked 0 Times in 0 Posts
Default insert into db

Hi,
I have a table called addressbook.
it contains an email field.
I have that the user enter his list of emails into this table but if the email already exists the new records just be added?
what should i do?
that is my code


do while not rs4.eof
if rs2("email")<> strEmail then
sql = "INSERT INTO AddressBook(email,ID)"
sql= sql & " VALUES ('"
sql=sql & strEmail & "', '"
sql=sql & "1" & "');"
conn.execute(SQL)

rs4.moveNext
Loop
next


 
Old May 9th, 2005, 11:50 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

Create a Key based on username and email address. This constraint will be violated if a user enters an email address that already exists. You can then trap the error in your code and notify the user.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Attempting to Insert Value into DB Query Snuffles ASP.NET 2.0 Basics 2 April 2nd, 2007 08:17 AM
Insert Variable Value into DB Deano252 ASP.NET 2.0 Basics 1 June 24th, 2006 03:21 AM
Insert into db error keyvanjan Classic ASP Databases 1 December 5th, 2005 07:30 AM
can't insert in db darkhalf Classic ASP Databases 11 January 12th, 2005 06:48 AM
Unable to INSERT INTO db nvillare Classic ASP Databases 6 August 26th, 2003 10:29 AM





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