Results 1 to 3 of 3

Thread: Preventing Duplicate DB values [resolved]

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2002
    Posts
    492

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

  2. #2
    Hyperactive Member gtilles's Avatar
    Join Date
    Dec 2004
    Location
    Planet Earth
    Posts
    394

    Re: Preventing Duplicate DB values

    VB Code:
    1. on error resume next
    2.  
    3. rstCustomers.AddNew
    4. rstCustomers("cst_name") = Request.Form("name")
    5. rstCustomers.Update
    6.  
    7. if err.number<>0 then
    8.  'your options
    9.  'response.redirect "DataSubmitted.html"
    10.  'response.write "Data already submitted!"
    11. 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.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2002
    Posts
    492

    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
  •  



Click Here to Expand Forum to Full Width