Data Debugging Question

Results 1 to 2 of 2

Thread: Data Debugging Question

  1. #1
    Join Date
    Dec 1969

    Default Data Debugging Question

    What (syntactically) is the best way to trap the error when a page tries to enter a duplicate entry into a key field in a database? <BR><BR>Thanks! <BR>Conrad

  2. #2
    Join Date
    Dec 1969

    Default RE: Data Debugging Question

    Well, <BR><BR>You can contain your sql statement and use On Error Resume Next but if you&#039;re using access this won&#039;t help because the error would be an ADO error and not a VBS error so it wouldn&#039;t be in the err object. If you&#039;re using SQL server you can use it&#039;s error message. <BR><BR>OR, you can check for the existance of a record first before you try to add it, which puts more load on the server but isn&#039;t terrible. <BR><BR>Just do:<BR><BR>SQL = "Select * From MyTable Where KeyField = " & Key<BR><BR>If MyRs.EOF Then<BR> &#039;Do Insert<BR>Else<BR> &#039;Show error message<BR>End If<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