Solved

Detecting Errors while using ADO

Posted on 1998-12-22
1
167 Views
Last Modified: 2013-12-25
I have checked many ASP books, including the "Programming Active Server Pages" from MS.  They all talk about how to use the ADODB Connection object and the recordset object to get or update data.  None of these books talk about how to detect any errors.  For example, I am inserting multiple records into an Access table.  Since the records have the same values, I should get some sort of errors from somewhere and remind the user to change the data.  How could I get that error?
0
Comment
Question by:akhaligh
1 Comment
 
LVL 6

Accepted Solution

by:
PBall earned 50 total points
ID: 1857435
at any point before executing the command, you can do the following:

-- I suggest you put your routine in a sub / function to isolate the problem locally.

Sub getRecords

   Dim rs

   On Error Resume Next   'trap for error

   Set rs = Server.CreateObject("ADODB.Recordset")

   rs.Open "getRecords",strConnection,adOpenForwardOnly,adLockReadOnly,adCmdStoredProc

   'if for some reason, the previous command fails, do this...

   If Err.Number > 0 Then
     Response.Write "Error getting record"
     Err.Clear
   End If


   On Error Goto 0  'disable error trap

End Sub
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Learn by example how to specify CSS selectors for Selenium WebDriver test automation software.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now