E
E
elah022017-07-12 18:07:10
Browsers
elah02, 2017-07-12 18:07:10

C#-SQLite Error: Database is locked, why?

string filename = "operapass.txt";
            StreamWriter Writer = new StreamWriter(filename, false, Encoding.UTF8);
            string db_way = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\Opera Software\\Opera Stable\\Login Data";
            string db_field = "logins";
            byte[] entropy = null;
            string description;

            DataTable DB = new DataTable();
            string sql = string.Format("SELECT * FROM {0} {1} {2}", db_field, "", "");
            using (SQLiteConnection connect = new SQLiteConnection(string.Format("Data Source={0};", db_way)))
            {
                SQLiteCommand command = new SQLiteCommand(sql, connect);
                SQLiteDataAdapter adapter = new SQLiteDataAdapter(command);
                adapter.Fill(DB);

                int rows = DB.Rows.Count;
                for (int i = 0; i < rows; i++)
                {
                    Writer.Write(i + "{" + Environment.NewLine);
                    Writer.Write("\turl     : " + DB.Rows[i][1] + Environment.NewLine);
                    Writer.Write("\tlogin   : " + DB.Rows[i][3] + Environment.NewLine);

                    byte[] byteArray = (byte[])DB.Rows[i][5];
                    byte[] decrypted = DPAPI.Decrypt(byteArray, entropy, out description);
                    string password = new UTF8Encoding(true).GetString(decrypted);
                    Writer.Write("\tpassword: " + password + Environment.NewLine + "}" + Environment.NewLine + Environment.NewLine);

                    listBox1.Items.Add(DB.Rows[i][1]);
                    listBox2.Items.Add(DB.Rows[i][3]);
                    listBox3.Items.Add(password);
                }
            }
            Writer.Close();

Here is the code, it gives an error DataBase is locked, why? I want to make a password backup program for Internet Explorer, Chrome and Opera. Can you tell me why this error?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
elah02, 2017-07-12
@elah02

I decided by copying this file to where the program is located, and then I turn to it)

A
Alexander Kuznetsov, 2017-07-13
@DarkRaven

In general, the problem could be that the database was opened by its owner. Because SQLite is single-threaded, then when you open it, the process locks the database file so as not to damage the data.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question