Error handling problems

Results 1 to 3 of 3

Thread: Error handling problems

  1. #1
    Keith Railton Guest

    Default Error handling problems

    Is there anyway to (for example) add a new record to a table and catch errors efficiently? I&#039m aware that you can use &#039On Error Resume Next&#039, but is there a way to do the following...?<BR><BR>A user inputs a lot (a LOT) of data into a form. Basic client-side validation checks are carried out on the data and the user is only allowed to submit the form once the entered data has passed. So far, so good. Now, once the form has been submited, we attempt to add the data to a table as a new record. However, if the database generates an error (like "INSERT statement conflicted with TABLE CHECK constraint", or whatever) all the user&#039s hard work is lost, even if we catch the error using the On Error Resume Next, as the database will simply terminate the whole rcdset.Update() statement!<BR><BR>So. Is there a way to add a new record, one field at a time, so that we can handle an error after submiting each FIELD to the database, rather than after adding a whole record? Or some other way around this? I&#039ve been pullling my hair out looking for a way to do this!<BR><BR>Any help would be gratefully received,<BR><BR>Thanks,<BR><BR>Keith.

  2. #2
    Join Date
    Dec 1969

    Default RE: Error handling problems

    You didn&#039t say what type of database, but it looks like SQL Server. There is a Constraint on a Table that you need to either change or comply with. Narrow it down to which field is causing the error, then check the field type. Also compare your client side validation rules against the database table constraints. You may be trying to put a text field (isn&#039t all data from form text boxes VARIANT types?) into a number or date field.<BR><BR>At this point, if you put a bandaid on the problem by creating a new record, then editing and updating it for each field, you will get the problem again in the future on your next project with this table. The correct solution is to change your client side validation script to conform to the database table constrant.

  3. #3
    Keith Railton Guest

    Default RE: Error handling problems

    I was afraid that would be the solution! It seems such a waste (of both time and resources) to perform the same validation checks twice (at both the client side and by the database&#039s constraints)...

Posting Permissions

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