Trap the SQL error

Results 1 to 2 of 2

Thread: Trap the SQL error

  1. #1
    Pari Guest

    Default Trap the SQL error

    how do i trap the error in INSERT statement??<BR><BR>i.e if i insert a record thru asp page , but it violates the databse rules(e.g. pri key), it displays a technical error msg, how do i give a user freindly error message?<BR><BR>thnx in advance<BR>pari

  2. #2
    Brad Kingsley Guest

    Default RE: Trap the SQL error

    You can it a couple of ways. You can use On Error Resume Next before the insert statement in your VBScript code, then check the err.number to see if it is non-zero after the insert. Or, better yet, if you are using SQL Server, wrap the statement into a stored procedure - then check the @@ERROR variable after the insert statement.<BR><BR>-Brad Kingsley, MCP - NT, IIS4<BR>Reliable Windows NT Web Hosting<BR>ORCS Web, Inc -<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