How to delete the SQLLite file currently in use ?, Current sqllite
I searched a lot from the Internet, and the routines were almost the same, but I could not do it myself. Why not? If not, no one else will be able to get involved. After a while, I went back to get afternoon tea. Again, I suddenly realized, What? This is simple.
The initial code is as follows:
Helper. GetConnectionString (schoolStr); // gets the current connection string
Using (ConnectionBase conn = ConnectionManager. Instance. Pop ())
{
If (conn. State! = ConnectionState. Open)
Conn. Open ();
Try
{
Helper. GetConnectionString (schoolStr); // gets the current connection string
Var curSchoolInfo = schoolDAL. SelectDetail (schoolStr );
If (curSchoolInfo! = Null)
SchoolInfoList. Add (curSchoolInfo );
}
Finally
{
Conn. Close ();
Conn. Dispose ();
GC. Collect ();
GC. WaitForPendingFinalizers ();
}
}
The modified code is as follows:
Just remove the red font and put it in the pink font.
It took more than two hours to solve this simple problem.
Note the code for the blue Font:
If some code is not added with a blue font, it will be released on the surface. Otherwise, why can't I release the connection to the db file after close () and Dispose? Q. Du Niang, there are several answers: Close (), Dispose (), but still not. Ask du Niang again and give the following answer:
The reason is that when sqllite executes the SQLiteConnectionHandle. Dispose () operation, the connection is not actually released. The connection can be released only after the CLR garbage collection is called.