Windows Mobile - Keeping SQLite Database Connection Open
I am using ADO.NET Provider on Windows Mo开发者_如何学Cbile (C#) to connect to SQLite database.
Will keeping database connection open for application life create any issue? I am thinking to keep it open because,
It will not allow user to delete database file (as it's already in use).
It will not allow other processes to modify it (as it's already in use).
Does not require to open connection each time.
Please let me know if there will be any issue with it.
The best way is to keep reference of the connection object in a static way. You should know that the connection can drop after a while, and you must prepare the code to handle reconnection.
Something like clsDbUtils.getConn() would do the job inside if sees the connection is no longer valid.
精彩评论