如何解决“数据库文件被锁定数据库被锁定”在Sqlite中 [英] How to resolve "The database file is locked database is locked" in Sqlite
本文介绍了如何解决“数据库文件被锁定数据库被锁定”在Sqlite中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在窗口7中使用以下代码。
我想获得我的谷歌浏览器历史记录。我使用以下代码
I am using following code in window 7.
i want to get my google chrome history. i am using following code
private void button1_Click(object sender, EventArgs e)
{
label1.Text = "Google crome";
string Google = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + @"\\Google\\Chrome\\User Data\\Default\\History";
SQLiteConnection cn = new SQLiteConnection("Data Source=" + Google + ";Version=3;New=False;Compress=True;");
cn.Open();
SQLiteDataAdapter DA = new SQLiteDataAdapter("select url,title,visit_count,last_visit_time from urls order by last_visit_time desc",cn);
DataSet ds = new DataSet();
DA.Fill(ds);
dataGridView1.DataSource = ds.Tables[0];
cn.Close();
}
按钮但是它给出了
on button but it give
"The database file is locked database is locked" error..
我们如何解决它请求帮助我.........
how we can resolve it plese help me.........
推荐答案
你只有文件夹路径string Google = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)+ @\\Google \\Chrome \\ User Data \\Default \\History;
设置数据源
时需要提供数据库文件路径,如数据Source = c:\ mydb.db;
每次完成后关闭连接。您可以使用USING
块
例如:
you only have folder pathstring Google = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + @"\\Google\\Chrome\\User Data\\Default\\History";
when you setData Source
you need to give database file path likeData Source=c:\mydb.db;
close the connection each time after you're finished with it. you can useUSING
blocks
e.g:
using (SQLiteConnection conn = new SQLiteConnection(connectionString))
{
conn.Open();
// do something with your connection
}
要解决这个问题,只需将历史文件复制到其他文件,历史记录1即可。并使用sqlite函数打开它。
To solve this just copy "History" file to other, "History.1" for exemple. And open it with sqlite function.
这篇关于如何解决“数据库文件被锁定数据库被锁定”在Sqlite中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文