I am developing WP8 app on VS 2012 Express. Installed SQLite for Windows Phone and Sqlite-net. And imported SQLite for Windows Phone as references.
However when I was trying to build the project it says:
Error 1 The type or namespace name 'Community' could not be found (are you missing a using directive or an assembly reference?)
And
Error 4 The type or namespace name 'Sqlite3' could not be found (are you missing a using directive or an assembly reference?)
What did I miss?
I think you forgot to add USE_WP8_NATIVE_SQLITE to your conditional compilation symbol.
#if USE_CSHARP_SQLITE
using Sqlite3 = Community.CsharpSqlite.Sqlite3;
using Sqlite3DatabaseHandle = Community.CsharpSqlite.Sqlite3.sqlite3;
using Sqlite3Statement = Community.CsharpSqlite.Sqlite3.Vdbe;
#elif USE_WP8_NATIVE_SQLITE
using Sqlite3 = Sqlite.Sqlite3;
using Sqlite3DatabaseHandle = Sqlite.Database;
using Sqlite3Statement = Sqlite.Statement;
I tested it, seems to be a bit problem with Windows phone 8 and Sqlite.
First thing to solve your problem is, to add the "Community.Csharpsqlite.WP" reference to the app. To do this, open the Nuget package manager and type "csharpsqlite" and install the resultant nuget package in your app. This resolves both the above issues you mentioned in your question. but agian, raises another problem. There are some incompatible methods in between "Community.Csharpsqlite.WP" and SQLite.cs file from "sqlite-net". One solution for this is to manually modify the methods in SQLite.cs to resolve the incompatibilities.
Alternatively, if the above process doesn't work out for you, then use the process of WP7 sqlite as mentioned in the dotnetslackers link. Test this in a separate project and hopefully this should work.
I got it working on Windows Phone 8 without csharpsqlite.
Peterhuene created a wrapper for SQLite which you can get from GitHub. No csharpsqlite needed anymore. The readme section contains all information needed.
A detailed description of how to set it up can also be found here on CodeProject.
I'm assuming you followed the instruction in this post
In the post there is an instruction that you add a c++ project to your solution named Sqlite. You get it from github. Admittedly this is very well hidden within the post and is easy to miss.
After including the c++ project to your solution you should add a reference to it from your C# project.
Add reference -> solution -> choose the c++ "Sqlite" project As a reference
After that, and adding the build constant USE_WP8_NATIVE_SQLITE it should work.
In SQLite.cs, there are several places you will see such lines
#if USE_CSHARP_SQLITE
...
...
#elif USE_WP8_NATIVE_SQLITE
...
...
Just replace the codes inside #if USE_CSHARP_SQLITE with the codes inside #elif USE_WP8_NATIVE_SQLITE and you are good to go. Or there is also a short method. Go to properties->build and after ; add "USE_WP8_NATIVE_SQLITE" and rebuild the solution. This worked for me
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With