Make SQLite connection fail if database is missing? (deleted/moved)

前端 未结 6 524
终归单人心
终归单人心 2021-01-18 11:39

I have the following method inside class DBConnection. I call the method like this: SQLiteConnection conn = DBConnection.OpenDB(); when I want to o

6条回答
  •  悲哀的现实
    2021-01-18 12:33

    Don't catch at that level. Instead, SQLiteConnection should implement IDisposable, meaning you should just return the open connection and allow calling code to handle any exceptions, as well as rely on the Dispose method to close the connection.

提交回复
热议问题