How to delete the SQLLite file currently in use ?, Current sqllite

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.