mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
fix not closing the db connection after opening
This commit is contained in:
parent
1ed7d34200
commit
f4d762c19b
1 changed files with 17 additions and 12 deletions
|
|
@ -27,20 +27,25 @@ namespace Wox.Plugin.BrowserBookmark
|
||||||
if (string.IsNullOrEmpty(PlacesPath) || !File.Exists(PlacesPath))
|
if (string.IsNullOrEmpty(PlacesPath) || !File.Exists(PlacesPath))
|
||||||
return new List<Bookmark>();
|
return new List<Bookmark>();
|
||||||
|
|
||||||
|
var bookmarList = new List<Bookmark>();
|
||||||
|
|
||||||
// create the connection string and init the connection
|
// create the connection string and init the connection
|
||||||
string dbPath = string.Format(dbPathFormat, PlacesPath);
|
string dbPath = string.Format(dbPathFormat, PlacesPath);
|
||||||
var dbConnection = new SQLiteConnection(dbPath);
|
using (var dbConnection = new SQLiteConnection(dbPath))
|
||||||
|
|
||||||
// Open connection to the database file and execute the query
|
|
||||||
dbConnection.Open();
|
|
||||||
var reader = new SQLiteCommand(queryAllBookmarks, dbConnection).ExecuteReader();
|
|
||||||
|
|
||||||
// return results in List<Bookmark> format
|
|
||||||
return reader.Select(x => new Bookmark()
|
|
||||||
{
|
{
|
||||||
Name = (x["title"] is DBNull) ? string.Empty : x["title"].ToString(),
|
// Open connection to the database file and execute the query
|
||||||
Url = x["url"].ToString()
|
dbConnection.Open();
|
||||||
}).ToList();
|
var reader = new SQLiteCommand(queryAllBookmarks, dbConnection).ExecuteReader();
|
||||||
|
|
||||||
|
// return results in List<Bookmark> format
|
||||||
|
bookmarList = reader.Select(x => new Bookmark()
|
||||||
|
{
|
||||||
|
Name = (x["title"] is DBNull) ? string.Empty : x["title"].ToString(),
|
||||||
|
Url = x["url"].ToString()
|
||||||
|
}).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
return bookmarList;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue