Check For Duplicate Data Entry Before attempting to add a new record!
Any good database design will include some measure of indexing and referential integrity. If these are Greek words to you, don't worry. The upshot is that database development and ASP database connectivity coding should not permit or force duplicate information in your database. It's all well and good that you may have thrown together a quick Access database with all default values (thus ensuring the fewest end user errors but not necessarily the most astute design) but we will take steps now to code around any flaws inherent in the database itself - if they exist.
For instructional purposes, we will assume that you have required four inputs; First name, Last Name, Company, and Phone Number. We will also assume that you have preformatted the phone number to a consistent format at the validation stage (not a bad idea - hint, hint!). These four string values, by our rules, must be unique to permit a new data record. You should code for record updates versus inserts based upon same name but new company or new phone (I would count same name and differing company and phone as a new entry) but we will skip that here.
The pseudo code for this would look something like:
declare dbConnect variable
declare dbRecordset variable
Open connection
Open recordset containing FirstName,LastName,Company,Phone values
Check if all four values fit the first record
If YES, set a flag to stop checking
If no flag is set, check the next record (until done)
If Flag is set
Do Nothing - no need, record exists
Otherwise
Close recordset and reopen with all datafields
Add user input to new record
Close recordset and data connection.
That takes care of our online database work! Not too intense at all was it? All that remains now is to finish our task by sending ourselves the message by email...
Food
For
Thought
