M
M
martensit2019-11-29 18:26:40
SQLite
martensit, 2019-11-29 18:26:40

Why can't I delete a database in c# after working with it?

using (SQLiteConnection db = new SQLiteConnection("Data Source=" + @"C:\db" + ";Version=3;"))
{
    db.Open();
    SQLiteCommand cmd = db.CreateCommand();
    cmd.CommandText = "SELECT * FROM moz_cookies";
    using (var reader = cmd.ExecuteReader()) while (reader.Read()) if (Convert.ToString(reader["baseDomain"]) == dm)
    {
        lst.Add(Convert.ToString(reader["name"]));
        lst.Add(Convert.ToString(reader["value"]));
    };
    db.Close();
}
File.Delete(@"C:\db");

Error that "C:\db" is being used by another process

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
martensit, 2019-11-29
@martensit

SQLiteCommand cmd also needed to be wrapped in using...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question