-1

I have a data.db file and I want to delete some data so use this code :

using (var db = new LiteDatabase("Filename=data.db;upgrade=true"))
        {
            var collection = db.GetCollection<Capture>("capture");

            //show db count before delete
            MessageBox.Show("COUNT : " + collection.Count().ToString());

            var col = db.GetCollection<Capture>("capture");
            var data_list = col.Find(Query.All(), 0, 3);
            foreach (var row in data_list)
            {
                //show row id before delete
                MessageBox.Show(row.Id.ToString());

                col.Delete(row.Id);
            }

            //show db count after delete
            MessageBox.Show("COUNT : " + collection.Count().ToString());

            this.Close();

and this code work fine but before run code I can open the data base with LiteDB Viewer without any error but after when I want to verifie if the data was deleted LiteDB Viewer gives me that error : Selected file is invalid or not supported

anynon can help me please. and thanks in advance.

BazSaraa
  • 11
  • 4
  • Hi BazSaraa, glad to know you've found the solution to resolve this issue! Please consider accepting it as an answer to change its status to Answered. It will also help others to solve a similar issue. See [can I answer my own question..](https://stackoverflow.com/help/self-answer), Just a reminder :) – Housheng-MSFT Jul 14 '22 at 08:27

1 Answers1

0

It's about the version of LiteDB in NuGet Package Manager, make sure that are the same (.db file and in the project)

BazSaraa
  • 11
  • 4