Click here to Skip to main content
15,888,733 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
VB
Private Function CheckIfOccupationExists(ByRef rstIn As ADODB.Recordset, ByRef cTestOcc As Object, ByRef cTestType As String) As Boolean

        Dim lTestOccFound As Boolean

        lTestOccFound = False
        'UPGRADE_WARNING: Couldn't resolve default property of object cTestOcc. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
        If Len(Trim(cTestOcc)) = 0 Then
            lTestOccFound = True
        Else
            'UPGRADE_WARNING: Use of Null/IsNull() detected. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="2EED02CB-5C0E-4DC1-AE94-4FAA3A30F51A"'
            If Not IsDBNull(cTestOcc) Then
                rstIn.MoveFirst()
                Select Case cTestType
                    Case "r", "m", "d", "I"
                        'UPGRADE_WARNING: Couldn't resolve default property of object cTestOcc. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
                        rstIn.Find("Occ_code=" & cTestOcc)
                    Case "D"
                        'UPGRADE_WARNING: Couldn't resolve default property of object cTestOcc. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
                        rstIn.Find("Dep_occ=" & cTestOcc)
                End Select
                lTestOccFound = Not rstIn.EOF
            End If
        End If
        CheckIfOccupationExists = lTestOccFound

    End Function
Posted

1 solution

Could if be that this test is failing:
VB
If Len(Trim(cTestOcc)) = 0 Then

You try to pass the cTestOcc to Trim function but if the value of the object is null from the database (DBNull) then the Trim will fail.

Try adding a parameter validation first:
VB
If cTestOcc = DBNull.Value Then
...
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 5-Jan-12 19:40pm    
Right, my 5. Also note that there is no DBNull.IConvertible.ToString, for a good reason.
--SA
Wendelius 6-Jan-12 6:12am    
That's true :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900