system.data.sqlite

How perform SQLite query with a data reader without locking database?

笑着哭i 提交于 2019-12-01 03:31:30
I am using System.Data.Sqlite to access SQLite database in C#. I have a query which must read through rows in a table. While iterating through the rows and while the reader is open, certain SQL updates must be performed. I am running into a "database is locked" exception. The SQLite documentation states: When a process wants to read from a database file, it followed the following sequence of steps: Open the database file and obtain a SHARED lock. The documentation further states about "SHARED" locking: The database may be read but not written. Any number of processes can hold SHARED locks at

HOWTO: SQLite with EntityFramework and Code-First

a 夏天 提交于 2019-11-30 13:11:10
问题 I am trying to create an embedded SQLite database on the fly with the EF however, I can't get it to work, the database file is never getting created. I have EF 4.2 and latest version SQLite Here is what I have app.config <?xml version="1.0"?> <configuration> <system.data> <DbProviderFactories> <remove invariant="System.Data.SQLite"/> <add name="SQLite Data Provider" invariant="System.Data.SQLite" description=".Net Framework Data Provider for SQLite" type="System.Data.SQLite.SQLiteFactory,

Sqlite Online Backup Using System.Data.Sqlite

给你一囗甜甜゛ 提交于 2019-11-30 12:40:38
问题 How can a sqlite database be backed up in native C# code while the database is still online? All of the online backup api examples are in C code. 回答1: The online backup API was added to System.Data.Sqlite in version 1.0.80.0 - April 1, 2012. You can create a database backup while there are other external connections like so using(var source = new SQLiteConnection("Data Source=ActiveDb.db; Version=3;")) using(var destination = new SQLiteConnection("Data Source=BackupDb.db; Version=3;")) {

C# SQLite Parameterized Select Using LIKE

*爱你&永不变心* 提交于 2019-11-30 11:30:26
I am trying to do an SQL query such as SELECT * FROM [TABLE] WHERE hostname LIKE '%myhostname%'; This works fine in plain SQL, but when I use System.Data.SQLite in C#, it only works with a literal, not a parameter, such as string sel = "SELECT * FROM [TABLE] WHERE hostname LIKE '%@host%'"; ... command.Parameters.AddWithValue("@host", "myhostname"); This returns no results. You can't do that. The parameters must be complete values - it's not just a string substitution into the SQL. You could do this instead: string sel = "SELECT * FROM [TABLE] WHERE hostname LIKE @host"; ... command.Parameters

Foreign key support in SQLite3

眉间皱痕 提交于 2019-11-30 09:31:43
问题 According to this thread from 2010, an "EnforceFKConstraints" connection string property was supposed to be implemented into future releases of SQLite. Does anyone know if the developers have gotten around to doing that? If not, is there another way I can enable foreign key support without doing "PRAGMA foreign_keys = ON" on each connection? I need this to make sure that deletes always cascade. 回答1: Future development of System.Data.SQLite ADO.NET provider for SQLite is done by this group.

System.Data.SQLite parameter issue

你离开我真会死。 提交于 2019-11-30 06:59:25
问题 I have the following code: try { //Create connection SQLiteConnection conn = DBConnection.OpenDB(); //Verify user input, normally you give dbType a size, but Text is an exception var uNavnParam = new SQLiteParameter("@uNavnParam", SqlDbType.Text) { Value = uNavn }; var bNavnParam = new SQLiteParameter("@bNavnParam", SqlDbType.Text) { Value = bNavn }; var passwdParam = new SQLiteParameter("@passwdParam", SqlDbType.Text) {Value = passwd}; var pc_idParam = new SQLiteParameter("@pc_idParam",

C# SQLite Parameterized Select Using LIKE

烈酒焚心 提交于 2019-11-29 16:54:10
问题 I am trying to do an SQL query such as SELECT * FROM [TABLE] WHERE hostname LIKE '%myhostname%'; This works fine in plain SQL, but when I use System.Data.SQLite in C#, it only works with a literal, not a parameter, such as string sel = "SELECT * FROM [TABLE] WHERE hostname LIKE '%@host%'"; ... command.Parameters.AddWithValue("@host", "myhostname"); This returns no results. 回答1: You can't do that. The parameters must be complete values - it's not just a string substitution into the SQL. You

EntryPointNotFoundException in SQLite after displaying FolderBrowserDialog

随声附和 提交于 2019-11-29 11:40:41
When using a 64-bit program System.Data.SQLite is throwing the following EntryPointNotFoundException: Unable to find an entry point named 'sqlite3_changes_interop' in DLL 'SQLite.Interop.dll'. Strangely it only occurs if Foreign Keys=True is specified in the connection string and more importantly only after I display a FolderBrowserDialog . I was browsing for a folder to display databases to load. The following code displays the problem: public Form1() { InitializeComponent(); // Exception below if this is displayed using (var diag = new FolderBrowserDialog()) { diag.ShowDialog(this); } var

Multiple access to a single SQLite database file via System.Data.SQLite and c#

試著忘記壹切 提交于 2019-11-29 09:34:34
问题 As I can read from SQLite FAQ it supports multiple processes reading (SELECT) and only one process writing (INSERT, UPDATE, DELETE) database at any moment in time: SQLite uses reader/writer locks to control access to the database. When any process wants to write, it must lock the entire database file for the duration of its update. But that normally only takes a few milliseconds. Other processes just wait on the writer to finish then continue about their business I'm using System.Data.SQLite

What is the first bytes in a Blob column SQlite Adobe AIR? Blob Sizeinfo?

杀马特。学长 韩版系。学妹 提交于 2019-11-29 08:52:12
I have identified a random series of bytes inserted into any blob field when the database is manipulated via Adobe AIR. (from my results it appear to always start with bytes[12, ...] but I'm not sure of that) I think it's a sizeinfo of the bytes, let me explain how I came to this conclusion. First my context : I manipulate sqlite databases through Adobe AIR (client-side) and System.data.sqlite (C# server-side) With System.data.sqlite if I read a Sqlite db filled with BLOB by Adobe AIR I have to get ride of those bytes appended in the beginning by AIR and then I have the binary data all well