私は、try / catch/finallyブロックを使用して開いているデータリーダーを閉じていました。
Dim dr As MySqlDataReader = Nothing
Try
dr = DBConnection.callReadingStoredProcedure("my_sp")
Catch ex As Exception
' the caller will handle this
Throw ex
Finally
If dr IsNot Nothing Then dr.Close()
End Try
しかし、「Using」VBキーワードを使用する方がよりクリーン(そしていくらか高速)である必要があると思います。
Using dr As MySqlDataReader = DBConnection.callReadingStoredProcedure("my_sp")
End Using
' dr is surely disposed, but is it closed?
IDisposeインターフェース(使用に必要)はDataReaderでCloseを実行しますか?