Results 1 to 5 of 5

Thread: [Resolved] Error handling in class module

Threaded View

  1. #1

    Thread Starter
    Member
    Join Date
    Mar 2005
    Posts
    52

    Resolved [Resolved] Error handling in class module

    Friends,

    Following is a method in one of my VB6.0 class that I intend to deploy as COM+ application. I have a phobia handling errors... I guess. Please comment on the simple error handling I have used. And any suggestions/advise is highly appreciated.
    Thanks in advance!

    "RaiseError" is a sub that simply does
    VB Code:
    1. err.raise eNo, eSrc, eDesc


    VB Code:
    1. Public Function GetCustomClients(ByVal bRegClient As Boolean) As ADODB.Recordset
    2.  
    3.   '==================================================
    4.   '  Parameters In: Boolean flag; True for regular clients
    5.   '  Returns      : Recordset containing - Client-Id, Client-Name
    6.   '                 and Description
    7.   '  Description  : Used to build the User-Interface (list-box)
    8.   '==================================================
    9.  
    10.   On Error GoTo errHandler
    11.  
    12.   Dim cClient As New ADODB.Command
    13.   Dim pFlg As ADODB.Parameter
    14.  
    15.   eNo = 0                   'declared form-level
    16.   eDesc = vbNullString                                   'form-level
    17.   eSrc = "GetCustomClients"                           'form-level
    18.  
    19.   cClient.ActiveConnection = ConnStr
    20.   cClient.CommandType = adCmdStoredProc
    21.   cClient.CommandText = "qryCustomClients"
    22.  
    23.   Set pFlg = cClient.CreateParameter("bFlg", adBoolean, adParamInput, , bRegClient)
    24.   cClient.Parameters.Append pFlg
    25.  
    26.   Set GetCustomClients = cClient.Execute()
    27.  
    28. errExit:
    29.   Exit Function
    30.  
    31. errHandler:
    32.   If Err.Number > 0 Then
    33.     eNo = Err.Number
    34.     eDesc = Err.Description
    35.     Err.Clear
    36.     On Error GoTo 0
    37.     Call RaiseError
    38.   End If
    39. End Function
    Last edited by vbXML; Jun 21st, 2005 at 07:55 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width