mardi 30 juin 2015

Getting TypeLoadException when using Sqlite-WinRT

i am developing a Windows Phone 8.1 app (WinRT) and i want to add support for SQLite. I have added the SQLite for Windows Phone extension to the project and also added the SQLite-WinRT wrapper. I also changed the build configuration to x86 so it can run in the emulator. My problem is: When i try to open a connection to a database file (either create or just open) i get a TypeLoadException. My code to open the connection is like this:

using (var db = new SQLiteWinRT.Database(ApplicationData.Current.TemporaryFolder, "Database.db"))
        {
            await db.OpenAsync(SqliteOpenMode.OpenOrCreateReadWrite);
            await db.ExecuteStatementAsync(@"create table if not exists MyTable ( ID integer not null primary key autoincrement, Name varchar(150) not null);");

            await db.ExecuteStatementAsync(@"insert into MyTable (Name) values ('Rafael');");
        }

When the first line is executed i get this error:

enter image description here

Here is a list of references in my project:

enter image description here

Any help is appreciated. Thank you all.

SQLite random() rows but 1 of them must have a specific value?

So, I am developing a kind of Quiz game, the game will have a question on the screen and below 4 buttons, which will be filled with 1 right answer and 3 wrong answers. Simple right? I'm trying to use the following rawQuery() to load 4 answers, all of them must be random, except the right answer that has to appear.

SQLite:

myCursor = db.rawQuery("SELECT * FROM Answers WHERE QuestionID = 3 ORDER BY RANDOM() LIMIT 4", null);

So, QuestionID is the field that is specifying which question is being displayed to load the proper answers. I'll need to have a lot of answers so that the player can't memorise them. Is something like this pseudo-code possible?

myCursor = db.rawQuery("SELECT * FROM Answers WHERE QuestionID = 3 ORDER BY RANDOM('WHERE RightWrong = 1 LIMIT 1') LIMIT 4", null);

RightWrong is the field that tells if it's the right answer or not (inside the DB), it's an INT, if it is set to 1 then it is the correct answer.

I'm using SQLiteAssetHelper with SQLite DB Browser.

SQLite extensions in BIRT

I have an Sqlite database local copy file (file.db). I am trying to make reports using BIRT. I have connected the data to BIRT using JDBC driver for SQLite. The problem is that in the SQLite database, we rely on .dll extensions to load views for the tables. How do I load that extension into BIRT to be able to see and work with the views?

Thanks

Copy SQLite database to android device

I'm already created my application used Android Studio. The database also completely done, when I run my application using emulator, that application can access the data in database. But the problem is when I try to run my application to the phone/android device, the database cannot be access. I run it by "choose a running device", where my phone already connected to the PC and already has been "root". thank you so much for help.

How do you synchronize data between SQLite and Azure in Android?

Ladies and Gentlemen,

I am currently working on an Android app, which is connected to a Microsoft Azure Backend. I have some trouble, synchronizing the app's database with the backend, as my current approach seems overly complicated. I searched for best practices / tutorials on synchronization without using SyncAdapter, but could not find anything that covers both storage and synchronization.

Functionality: A user can subscribe to a topic. This subscription shall be pushed to the Backend, so that the backend can send push notifications. So, the backend has to know, which users subscribed to which topics.

Task: Subscriptions are created and deleted on the Android app via a button click. They have to be stored offline in a database and also synced with Azure.

Current Approach: After reading multiple tutorials on databases and synchronization with android, I chose the following approach:

  • Subscriptions are directly saved in a SQLite database on the phone. Each subscription is saved with lastUpdated = now() and deleted = false. If a subscription is deleted, lastUpdated is updated and deleted is set to true.
  • A DataSynchronizer listens to updates and deletes on the subscription table. He stores the time of the last sync, lastSynced. For every update / insert / delete, he collects all subscriptions with lastUpdated > lastSynced and applies the changes via the MobileServiceClient provided by Microsoft Azure.

My question: Is there something you would do differently? As I said, this solution seems complicated and not like the best practice way.

Android SqliteAssetHelper copy user saved data

I am using SQLiteAssetHelper utility to manage the copying of the database from my asset folder. In the app, the user enters some data into the database and as soon as I upgrade the db, all the data gets deleted cause I have set setForcedUpgrade();. I heard you can use upgrade scripts, but I think they do not help me in this case as the data is unique for each user. How can I solve this?

sqlite database stack smashing while putting epoch time into integer field

I use sqlite database and it has one column for epoch time, I use its type as INTEGER because I don't find any other suitable type for that. When I try to add data in that field through my C program it shows me * stack smashing detected *. probably it is because i try to put epoch time to INTEGER field. But it allows only following types. The types supported by database: text,integer,real,blob,null. what would be suitable type and if it is INTEGER how to remove this error.