title: TRY CATCH not working when exception is raised from SQL Stored Procedure
body: <p>So, for some reason my TRY CATCH is not capturing the exception thrown by SQL server stored procedure.
  Basically, I execute a procedure and it does what it needs or raises an error. This error needs to be captured and raised in the VB app.
  What am I doing wrong? And yes, SQL does throw an error...</p>
  
  <pre><code>    Public Function InsertDetails(ByVal dBillingDate As Date) As Boolean
      Dim result As Boolean = False
      Dim bReturn As Boolean = True
      Try
          CleanUp(ObjCmd)
          ObjCmd = UpgradeHelpers.DB.AdoFactoryManager.GetFactory().CreateCommand()
  
          ObjCmd.CommandText = "usp_InsAfterHours"
          ObjCmd.CommandType = CommandType.StoredProcedure
          ObjCmd.CommandTimeout = 0
          ObjCmd.Connection = SQLServerDB
  
          'Get the parameters from the sproc
          ParametersHelper.DeriveParameters(ObjCmd, UpgradeHelpers.DB.AdoFactoryManager.GetFactory())
  
          With ObjCmd.Parameters
              ObjCmd.Parameters(1).Value = dBillingDate
          End With
  
          ObjCmd.ExecuteNonQueryAsync()
  
          Do While ObjCmd.Connection.State = ConnectionState.Executing
              LoopSet = ""
          Loop
  
      Catch ex As Exception
          If (TypeOf ex Is OleDb.OleDbException) Then
              RaiseError(DirectCast(ex, OleDb.OleDbException).ErrorCode, Me.GetType().Name &amp; ".InsertDetails", ex, DirectCast(ex, OleDb.OleDbException).Errors, g.sDatabaseUserName)
          Else
              RaiseError(CInt(ex.HResult), Me.GetType().Name &amp; ".InsertDetails", ex, , g.sDatabaseUserName)
          End If
  
          bReturn = False
  
      Finally 
          CleanUp(ObjCmd)
          result = bReturn
      End Try
  
      Return result
  End Function
  </code></pre>