I am curious of why I cannot dispose the dataview (dv) as shown in this code block.
VB Code:
  1. Private Sub FillMarketingPieceCombo()
  2.         Dim strSQL As String = _
  3.             "Select MarketingPiece From queMarketingPiece"
  4.         Dim con As New OleDbConnection(strCon)
  5.         Dim da As OleDbDataAdapter = _
  6.             New OleDbDataAdapter(strSQL, con)
  7.         Dim ds As DataSet = New DataSet
  8.         Try
  9.             da.Fill(ds, "MP")
  10.             Dim dv As DataView = ds.Tables("MP").DefaultView
  11.             cbMarketing.DataSource = dv
  12.             cbMarketing.DisplayMember = "MarketingPiece"
  13.  
  14.         Catch ex As Exception
  15.             MessageBox.Show( _
  16.                 ex.Message & vbNewLine & _
  17.                 ex.Source, _
  18.                 "Marketing Piece Error", _
  19.                 MessageBoxButtons.OK, _
  20.                 MessageBoxIcon.Error)
  21.         Finally
  22.             da.Dispose()
  23.             ds.Dispose()
  24.             dv.Dispose()
  25.             con.Dispose()
  26.         End Try
  27.     End Sub
I get the blue squiggly line under the dv.Dispose() with a message 'dv' is not declared. It is declared in the Try Catch Block and since I am using the Finally section of that TC Block why don't it recognize the declaration. Also does that mean my other Object disposals are being ignored since they are in the block and the declarations are outside of the block?