How do I catch a SQL error in VB6 while updateing a recordset?

I have this line in my code:
   adors2.Update
VB doesn't seem to catch any errors in data that cause this update to fail with the standard "on error" method.
How can I catch an update error?


yyuubum2Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ryan ChongCommented:
In vb6, we use "on error goto errorHandler" method to capture any error within your codes, sorry, there is no try ... end try statement in vb6, that's only available in vb.net
0
yyuubum2Author Commented:
Yes..but the   ADORS.UPDATE  error doesn't seem to trip a VB error condition.
VB doesn't know the recordset didn't update due to data problems.
Still looking ....
0
Leigh PurvisDatabase DeveloperCommented:
Have you examined the ADO errors collection after attempting your update?
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

yyuubum2Author Commented:
LPurvis:
Can you help me out here.
I'm not familiar with how to do that..
Maybe an example?
0
Leigh PurvisDatabase DeveloperCommented:
An example of examining the error collection after attempting some data update

Private Sub cmdADOErr_Click()
On Error GoTo errHere

    Dim cnn As New ADODB.Connection
    Dim errADO As ADODB.Error
   
    cnn.Open "Your Connect String"
   
    cnn.Execute "UPDATE tblTable SET Field1 = 'Leigh' WHERE FieldID = 1"
   
errHere:
    For Each errADO In cnn.Errors
        MsgBox errADO.Number & " : " & errADO.Description & " : " & errADO.NativeError
    Next
End Sub
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Leigh PurvisDatabase DeveloperCommented:
Did the errors collection prove revealing for you then?
(Not a briliant example I know - just a rough idea :-)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.