system.data.sqlite

Getting last inserted ID

感情迁移 提交于 2019-12-23 16:03:37
问题 I'm currently using the method below to get the ID of the last inserted row. Database.ExecuteNonQuery(query, parameters); //if another client/connection inserts a record at this time, //could the line below return the incorrect row ID? int fileid = Convert.ToInt32(Database.Scalar("SELECT last_insert_rowid()")); return fileid; This method has been working fine so far, but I'm not sure it's completely reliable. Supposing there are two client applications, each with their own separate database

Random error when testing with NHibernate on an in-Memory SQLite db

筅森魡賤 提交于 2019-12-23 07:47:43
问题 I have a system which after getting a message - enqueues it (write to a table), and another process polls the DB and dequeues it for processing. In my automatic tests I've merged the operations in the same process, but cannot (conceptually) merge the NH sessions from the two operations. Naturally - problems arise. I've read everything I could about getting the SQLite-InMemory-NHibernate combination to work in the testing world, but I've now ran into RANDOMLY failing tests, due to "no such

SQLite in-memory database backup in .NET

半腔热情 提交于 2019-12-23 07:01:14
问题 How to get the SQLite in-memory data base backed up? I create the database in my Windows application. I want to take a database backup when I will close the application. 回答1: You want the SQLite Online Backup API. As far as I know, System.Data.SQLite does not support it yet, so you'll need to write some code. The System.Data.SQLite Forum contains an example: http://sqlite.phxsoftware.com/forums/t/2403.aspx. As noted, when you patch System.Data.SQLite and call SQLite directly you do so at your

Integrating SQLite with a Windows application

∥☆過路亽.° 提交于 2019-12-23 03:54:06
问题 So I created a simple WPF application that allows a user to INSERT a string into a SQLite database (a .S3DB file). The user can also SELECT a string from the database and DELETE the string from the database...very simple application. I want to distribute this simple application, so I've created setup.exe file for the application by creating a new project and using the setup wizard on VS2010. When the user installs the application, it creates a "TestDatabase" folder in the Program Files

System.Data.SQLite BackupDatabase() throws “not an error”

冷暖自知 提交于 2019-12-22 18:34:58
问题 I'm using System.Data.SQLite (version 1.0.85.0) to connect with my SQLite database. I want to create backup of the database using SQLiteConnection.BackupDatabase() method, however it throws SQLiteException with message:"not an error" (repeated twice). Here is some code: SQLiteConnection cnnIn = new SQLiteConnection("Data Source=test.db;foreign keys=True"); SQLiteConnection cnnOut = new SQLiteConnection("Data Source=backup.db;foreign keys=True"); cnnIn.Open(); cnnOut.Open(); cnnIn

SQLite error when accessing first element in table using LINQ

穿精又带淫゛_ 提交于 2019-12-22 10:35:21
问题 I'm having the following issue when accessing a SQLite database using LINQ. Abreviated code looks like this: ... using System.Linq using System.Data.Linq using System.Data.Linq.Mapping using System.Data.SQLite ... DataContext sqltContext= new DataContext(sqltConnection); featureTable = sqltContext.GetTable<FeatureModel>(); count= featureTable.Count(); // count == 1 The following line fails with error: "SQL logic error or missing database\r\nunknown error" //currentFeature = featureTable.First

How does the SQLite Entity Framework 6 provider handle Guids?

拥有回忆 提交于 2019-12-22 02:27:10
问题 I am porting our product's database to SQLite from another product that supported Guids. As we know, SQLite does not support Guids. I've got created an entity framework 6 model from my database (database first) and I need to build a query from C# that compares the Guid to one passed from the code. The thing is I can't find any documentation on how the SQLite Entity Framework provider handles Guids. A web search didn't find anything useful for me, either. Just questions about using Entity

SQLite CreateDatabase not supported error

扶醉桌前 提交于 2019-12-21 20:40:47
问题 I'm using Entity Framework 4.2 CF with SQLite, but when i try to launch the application i got "CreateDatabase is not supported by the provider" error. This is my model mapping: protected override void OnModelCreating(DbModelBuilder modelBuilder) { #region NewsMapping modelBuilder.Entity<News>().ToTable("news"); modelBuilder.Entity<News>().HasKey(x => x.Id).Property(x => x.Id).HasColumnName("ID").HasColumnOrder(0); modelBuilder.Entity<News>().Property(x => x.Status).HasColumnName("STATUS");

Adding “System.Data.SQLite” as a reference

∥☆過路亽.° 提交于 2019-12-21 11:31:13
问题 when i was building my project done in asp.net & c#.net ,it produced the error as "The type or namespace name 'SQLite' does not exist in the namespace 'System.Data' (are you missing an assembly reference?" so, when i tried to add it as reference ,i was not able to find "System.Data.SQLite" in my library . how to overcome this problem.? 回答1: Try to search for System.Data.SQLite.DLL file (using windows explorer search) or if you have not yet installed it just download it from the net. For more

System.Data.SQLite parameterized queries with multiple values?

柔情痞子 提交于 2019-12-21 03:39:09
问题 I am trying to do run a bulk deletion using parameterized queries. Currently, I have the following code: pendingDeletions = new SQLiteCommand(@"DELETE FROM [centres] WHERE [name] = $name", conn); foreach (string name in selected) pendingDeletions.Parameters.AddWithValue("$name", name); pendingDeletions.ExecuteNonQuery(); However, the value of the parameter seems to be overwritten each time and I end up just removing the last centre. What is the correct way to execute a parameterized query