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.
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.
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.