SQL数据库已锁定

本文关键字:锁定 数据库 SQL | 更新日期: 2023-09-27 18:21:34

我想获取我遇到这个问题的浏览器的历史记录。我得到的错误是显示Database is locked的行using (SQLiteDataReader dr = cmd.ExecuteReader())

顺便说一句,我读了我的错误的相关帖子,但我仍然无法解决它。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SQLite;
namespace CrawlHistory
{
    class Program
    {
        static void Main(string[] args)
        {
            using (SQLiteConnection conn = new SQLiteConnection(@"Data Source=C:'Users'ASUS'AppData'Local'Google'Chrome'User Data'Default'History"))
            {
                conn.Open();
                using (SQLiteCommand cmd = new SQLiteCommand())
                {
                    cmd.Connection = conn;
                    cmd.CommandText = "Select * From urls";
                    using (SQLiteDataReader dr = cmd.ExecuteReader())
                    {
                        while (dr.Read())
                        {
                            Console.WriteLine(dr[1].ToString());
                        }
                    }
                }
            }
        }
    }
}

SQL数据库已锁定

已解决。它没有任何问题。你应该确保你已经关闭了"Chrome"。您可以从"任务管理器"中进行检查