I have a VB.net web service that was written a number of years ago and I "think" might have some issues.
I am not a VB.net guy really and have limited knowledge of Close Dispose protocols. Reading got me the following but I am still unclear.
https://stackoverflow.com/questions/4439409/open-close-sqlconnection-or-keep-open
My main concern is the handling of the MS SQL database, potential lock-ups etc. Have seen a few.
The following code is part of one function (truncated code) but you will see there are a number of 'Exit Function' lines.
I assume then that the 'Finally' code will not get executed and therefor that no Close / Dispose etc. will be execute ? The web service processing returns to the calling app after that Exit Function.
Is that an issue, not processing that 'Finally' chunk of code (Close/Dispose) ?
and If so I guess removing the Exit Function lines will address that ?
Or .. will putting a CloseDbConnection() before the Exit Function do just as well.
thanks
                        ElseIf AppMode = "Update" Then
                        InPhoneGUID = db.updateInPhoneScanner(returnedUID, AppMode, New List(Of String)(New String() {tmpl1}))
                        If Not InPhoneGUID = "" Then
                            r.Message = "PhoneScanner Templates Updated"
                            '   resultList.Add(r)    ' Doubling up on the Returned info ?
                            r.GenUID = InPhoneGUID
                            resultList.Add(r)
                            Return GetResponseTextForMobile(resultList)
                            Exit Function
                        Else
                            r.Message = "error 1,PhoneScanner Update Failed"
                            resultList.Add(r)
                            Return GetResponseTextForMobile(resultList)
                            Exit Function
                        End If
                        _Logger.Info("=== Invalid Account Type for PHONESCANNER ===")
                        r.Message = "error 1,Account Addition Inavild Type"
                        resultList.Add(r)
                        Return GetResponseTextForMobile(resultList)
                        Exit Function
                    End If
                End If          ' End  ===========  MAINLINE ROUTINE
                _Logger.Info("=== Invalid MODE ===")
                r.Message = "error 1,Inavild Mode Sent"
                resultList.Add(r)
                Return GetResponseTextForMobile(resultList)
                Exit Function
            End If
        End If
    Catch ex As Exception
        _Logger.Error(ex)
    Finally
        db.CloseDbConnection()
        If fingerPrintHelper IsNot Nothing Then
            fingerPrintHelper.Dispose()
        End If
        db = Nothing
    End Try
The db.CloseConnection is as follows ;
        Public Sub CloseDbConnection()
        Try
            mSqlconnection.Close()
            mSqlconnection.Dispose()
            mSqlconnection = Nothing
        Catch ex As Exception
            'Throw New Exception("CloseDbConnection : " & ex.Message)
        End Try
    End Sub
