Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sqlite.cs could not find sqlite3 and community

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?

like image 898
Nexus2020 Avatar asked Nov 28 '12 05:11

Nexus2020


5 Answers

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;
like image 178
piccoloaiutante Avatar answered Nov 19 '22 13:11

piccoloaiutante


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.

like image 27
nkchandra Avatar answered Nov 19 '22 14:11

nkchandra


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.

like image 2
Heinrich Ulbricht Avatar answered Nov 19 '22 14:11

Heinrich Ulbricht


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.

like image 1
iloveiniestaandowen Avatar answered Nov 19 '22 14:11

iloveiniestaandowen


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

like image 1
Bibaswann Bandyopadhyay Avatar answered Nov 19 '22 12:11

Bibaswann Bandyopadhyay