Hi Friends,
How to find unclosed datareader ?
example:
Try
If SUM_COMMAMT < 1 Then
MessageBox.Show("No Records Found")
Return Nothing
Exit Function
End If
rdr = cmd.ExecuteReader
While rdr.Read
<do something....>
End While
Catch ex As Exception
MessageBox.Show(ex, "Support Panel", MessageBoxButtons.OK, MessageBoxIcon.Error)
Finally
If Con.State = ConnectionState.Open Then
Con.Close() : cmd.Dispose() : Con.Dispose()
rdr.Close()
End If
End Try
Note: As per above code: If i get a message "No Records Found") (2nd line)
code will jump to Finally - right.
if so, i am getting an error in this line:
rdr.Close() so, i need to check the rdr before close the same.
How to do so ?