locked
Using SQLite in Windows Phone 8 with the VSIX package and sqlite-net RRS feed

  • Question

  • Hello,

    I have installed the new VSIX package for Windows Phone8 of SQLite ( http://www.sqlite.org/download.html#wp8 ). I use also sqlite-net ( https://github.com/praeclarum/sqlite-net ).

    The compilation is all good but at runtime when I tried to open the database I got this exception:

    System.NotSupportedException was unhandled by user code
      HResult=-2146233067
      Message=DllImport cannot be used on user-defined methods.
      

    At this location:

    [DllImport("sqlite3", EntryPoint = "sqlite3_open", 
    CallingConvention=CallingConvention.Cdecl)] public static extern Result O
    pen ([MarshalAs(UnmanagedType.LPStr)]
    string filename, out IntPtr db);

    Have I forget something to be able to use sqlite?


    http://wp7wonders.wordpress.com/





    Sunday, November 4, 2012 1:41 PM

Answers

  • At the BUILD conference, Peter Torr said a WinRT wrapper for SQLite will be released soon. He was using his own wrapper for the demo during his talk, and he said he will post it on his blog if the official one doesn't show up soon.
    Richard Woo
    Monday, November 5, 2012 9:23 PM

All replies

  • I just read in the SDK release note (http://msdn.microsoft.com/library/windowsphone/develop/jj206940(v=vs.105).aspx#BKMK_CommonLanguageRuntime) that P/Inovke is not supported.

    How can we use SQLite in our managed code/app?


    http://wp7wonders.wordpress.com/

    Sunday, November 4, 2012 1:54 PM
  • Have you had any luck with this? I can't find any straight documentation on it anywhere.

    Thanks

    Monday, November 5, 2012 5:03 AM
  • I am looking to but it appears you have to create a WIN Phone RT Component. Then from there write a wrapper around the SQLite bits then reference your RT Component in your C# project to take advantage of the C++ goods in your managed app, seems like a lot of work (albeit written once) to make the transition to SQLite. 

    Just to be clear there is literally no information on this topic anywhere.  Its all bits I got from the Build videos

    Wish they would have put out some examples after the build conference.


    Morgan Vermef


    • Edited by mvermef Monday, November 5, 2012 6:49 AM
    Monday, November 5, 2012 6:45 AM
  • Yes it was I heard too since. Maybe I'm too young to develop for WP8 because I don't know C++ ... It's like saying that a database is supported for an OS but there's no driver for your language, you are not going to use it.

    Matthieu


    http://wp7wonders.wordpress.com/

    Monday, November 5, 2012 11:49 AM
  • Thanks for the info. I guess I will stop wasting more time and stick to local storage for now. I thought it was announced in Build that SQLite would be "official" in WP8. Yet Microsoft hasn't built anything nice to use it. We'll have to wait and see.

    Monday, November 5, 2012 1:50 PM
  • think of it as a reusable for cross platform needs iOS/Android etc...  One wrapper to satisfy them all..  Therefore having code in C++ will cross the platform divide... D.R.Y. code.


    Morgan Vermef

    Monday, November 5, 2012 4:46 PM
  • my bridge is C# :) I use MonoTouch and MonoDroid - No wrapper needed. In Windows
    8 WinRT we can also use SQLite "as is" (provided by the VSIX package) too.

    http://wp7wonders.wordpress.com/

    Monday, November 5, 2012 4:56 PM
  • At the BUILD conference, Peter Torr said a WinRT wrapper for SQLite will be released soon. He was using his own wrapper for the demo during his talk, and he said he will post it on his blog if the official one doesn't show up soon.
    Richard Woo
    Monday, November 5, 2012 9:23 PM
  • Thank for the update, would be nice indeed to see an official wrapper.

    http://wp7wonders.wordpress.com/

    Monday, November 5, 2012 9:31 PM
  • one would have thought it would have been released the day the sdk was released... only makes sense...

    Morgan Vermef

    Monday, November 5, 2012 10:10 PM
  • Not sure if anybody knows about this one but in the meantime (while waiting for official wrapper) I've managed to do something with a project hosted in google named CSharp SQLite
    Tuesday, November 6, 2012 1:08 AM
  • Hi,

    I was also started building a sample Windows Phone 8 project with SQLite.

    I installed the extension "SQLite for Windows phone". Then I tried to add its SDK references to the project. but I didn't find it. I restarted Visual Studio 2012 and tried. But no luck.

    Usually I should see "Windows" option in the left side in reference manager , from there, I can check required extensions. But, I am not seeing it. did I miss something here?

    Also, could you please let me know once the Microsoft released nice Wrapper for SQLite for Windows Phone 8.


    Suresh

    Friday, November 30, 2012 4:27 PM
  • Also, could you please let me know once the Microsoft released nice Wrapper for SQLite for Windows Phone 8.

    You can let yourself know by visiting Peter Torr's blog and the Windows Phone Developer blog regularly.


    Friday, November 30, 2012 6:58 PM
  • Did you accidentally create a WP7 project? There is a "Targeting: Windows Phone 7.1" on your screenshot. Try upgrading the project to WP8, then you should see options below:

    Saturday, December 1, 2012 3:26 AM
  • I've slapped together this small C++/CLI wrapper for getting sqlite-net working on WP8 without csharp-sqlite (note: you'll need to use my fork of sqlite-net for now, though).

    https://github.com/peterhuene/sqlite-net-wp8

    I just wrote it today, so if you do use it, please let me know if you run into any bugs.

    Cheers.

    Thursday, December 20, 2012 7:46 AM
  • Do you have any sample to use sqlite-net-wp8 on Windows Phone 8 project ?
    Wednesday, December 26, 2012 8:03 AM
  • Take a look at this article: Working with SQLite in Windows Phone 8.
    • Edited by Peter Huene Monday, December 31, 2012 6:40 AM
    Monday, December 31, 2012 6:39 AM
  • Ok, I’m trying that. Database working, but i can’t find database file in Isolated Storage and database rewrite after updating the application.
    Thursday, January 3, 2013 9:18 PM