Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 537
  • Last Modified:

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?


0
yyuubum2
Asked:
yyuubum2
  • 3
  • 2
1 Solution
 
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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
 
Leigh PurvisDatabase DeveloperCommented:
Did the errors collection prove revealing for you then?
(Not a briliant example I know - just a rough idea :-)
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now