Wrox Programmer Forums
|
Pro VB Databases Advanced-level VB coding questions specific to using VB with databases. Beginning-level questions or issues not specific to database use will be redirected to other forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro VB Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 8th, 2004, 05:12 AM
Authorized User
 
Join Date: Nov 2003
Posts: 47
Thanks: 0
Thanked 0 Times in 0 Posts
Default Intercept ADO Errors

Hi

I have a small procedure which runs ADO commands (sent as strings):

Public Sub RunCmd(ByVal Sta As String)

Call OpenConnection

Set cmds.ActiveConnection = cnn1
cmds.CommandTimeout = 15
cmds.CommandText = Sta

On Error GoTo CmdErr

CmdRetry:
cmds.Execute

CmdErr:
' Error processing here....

End Sub

No error trapping occurs ! I seem not to be able to intercept errors, such as faulty table name, column name etc.

What should I do ?

Mike,
Bucharest
 
Old September 28th, 2004, 07:33 AM
Authorized User
 
Join Date: Sep 2004
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to Lalit_Pratihari
Default

Hi,

You can trap the error by reading the Err object.

Try this

CmdErr:
If Err.Number <> 0 then
      Msgbox "Error: " & Err.Description, "Alert"
      Err.Clear
      exit sub
end if

Hope this helps,

Lalit
Life Means More...;)





Similar Threads
Thread Thread Starter Forum Replies Last Post
ADO querying Excel errors nautica Excel VBA 0 April 28th, 2006 08:25 AM
Intercepting ADO Errors in VB6 mike123abc Pro VB Databases 1 January 28th, 2005 11:08 PM
ADO UPDATE Errors rborloz Pro VB Databases 0 January 20th, 2005 04:20 AM
Can't get errors to display with <html:errors> michaeldill JSP Basics 0 August 2nd, 2004 01:47 PM
Intercept data sent to printer & insert into DB tricia412 VS.NET 2002/2003 0 September 8th, 2003 02:14 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.