我有一个 SQLite 数据库,我希望从中读取记录并针对每条记录执行一段代码。
我正在使用带有 Try Catch INSIDE 的 While 循环...
代码如下:-
result = slcom.ExecuteReader()
'TODO: There is a problem with this while loop whereby if an ex is caught the connection
' to the database is closed.
While result.Read
Try
< do some stuff here >
Catch ex As Exception
incrementFailoverCount(result("fid"))
End Try
End While
result.Close()
问题是,一旦进入 Try 块并捕获了一个 ex,while 循环的下一次迭代就会失败,因为似乎在捕获 ex 的那一刻,与 SQLite 数据库的连接就关闭了,尽管连接属性表明它开了。
有任何想法吗 ???