insert only if no duplicate field exist

Results 1 to 2 of 2

Thread: insert only if no duplicate field exist

  1. #1
    Join Date
    Dec 1969

    Default insert only if no duplicate field exist

    i cant figure how to do the following. right now, i have a form, you fill it out and it submits to another page where an Insert Into SQL statement resides. However, i just tried to debug and found that i cant do an insert if a duplicate name exists (duh!). i have my db set to no duplicate on a certain field. how can i make the code look for a duplicate, if it finds one, state that one exists, if not exist then Insert Into...<BR><BR>here is my generic coding<BR>===<BR>dbPhysicalPath = Request.ServerVariables("APPL_PHYSICAL_PATH") & "fpdbstudents.mdb"<BR>Set dbConn = Server.CreateObject("ADODB.Connection")<BR>dbConn. Open = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ= " & dbPhysicalPath<BR>dbConn.Execute (SQL)<BR>===<BR><BR>Told you it was generic.. The SQL of course is the Insert Into statement<BR><BR>Thanx<BR>Chuck

  2. #2
    Join Date
    Dec 1969
    Los Angeles, CA

    Default RE: insert only if no duplicate field exist

    First you have to select from the Db where ColumnName = the name you wnat to insert (ColumnName will be the unique column). If a record exists then you give a message that that name exists, otherwise you insert the record<BR><BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts