|
-
Oct 5th, 2006, 11:32 AM
#1
Thread Starter
Hyperactive Member
Preventing Duplicate DB values [resolved]
On my ASP site I am getting the following error if I refresh the page once info has been sent to the DB. I see what is happening but what can i do to prevent this error from happening, is there a value that I can set to skipp the addition to the db if the info has already been added.
This is my error.
Microsoft OLE DB Provider for ODBC Drivers error '80040e2f'
[Microsoft][ODBC Microsoft Access Driver] The changes you requested to the table were not successful because they would create duplicate values in the index, primary key, or relationship. Change the data in the field or fields that contain duplicate data, remove the index, or redefine the index to permit duplicate entries and try again.
This is what i use to add data to the db
rstCustomers.AddNew
rstCustomers("cst_name") = Request.Form("name")
rstCustomers.Update
Any help is greatly appreciated.
Last edited by mrstuff68; Oct 12th, 2006 at 12:55 PM.
-
Oct 6th, 2006, 06:42 PM
#2
Hyperactive Member
Re: Preventing Duplicate DB values
VB Code:
on error resume next
rstCustomers.AddNew
rstCustomers("cst_name") = Request.Form("name")
rstCustomers.Update
if err.number<>0 then
'your options
'response.redirect "DataSubmitted.html"
'response.write "Data already submitted!"
end if
other then that you could do a sql select first to make sure the data doesn't already exist.
Truly, you have a dizzying intellect.
-
Oct 12th, 2006, 12:55 PM
#3
Thread Starter
Hyperactive Member
Re: Preventing Duplicate DB values
Thanks gtilles,
I have used this line to fix my problem, I dont know if this is a really good solution but at least it is a fix for now.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|