P Philip Prins Active Member Licensed User Longtime User Sep 28, 2022 #1 Hello, Do you need to close the resultset or cursor when you use Try Catch ? Example Code: Copy Try Dim RS As ResultSet = Do While Loop RS.close Catch RS.close 'Is this neccesary? End Try
Hello, Do you need to close the resultset or cursor when you use Try Catch ? Example Code: Copy Try Dim RS As ResultSet = Do While Loop RS.close Catch RS.close 'Is this neccesary? End Try
DonManfred Expert Licensed User Longtime User Sep 28, 2022 #2 Philip Prins said: Try Dim RS As ResultSet = Do While Loop RS.close Click to expand... the rs.close is never reached after the loop as it never ends.... B4X: Copy Dim RS As ResultSet = Do While rs.NextRow Loop RS.close Upvote 0
Philip Prins said: Try Dim RS As ResultSet = Do While Loop RS.close Click to expand... the rs.close is never reached after the loop as it never ends.... B4X: Copy Dim RS As ResultSet = Do While rs.NextRow Loop RS.close
Erel B4X founder Staff member Licensed User Longtime User Sep 28, 2022 #3 It is probably an overkill. Note that you can write it like this: Code: Copy Try Dim RS As ResultSet = Do While Loop Catch Log(LastException) End Try RS.close Assuming that it is a local SQLite db then there is no real reason for an unexpected error to happen. If it is a remote db then you should use a pool and make sure to close the connection (which will close other resources as well). Upvote 0
It is probably an overkill. Note that you can write it like this: Code: Copy Try Dim RS As ResultSet = Do While Loop Catch Log(LastException) End Try RS.close Assuming that it is a local SQLite db then there is no real reason for an unexpected error to happen. If it is a remote db then you should use a pool and make sure to close the connection (which will close other resources as well).