18

I am trying to find an API within WinRT that will allow me to create a local database that can be used to store data for an occasionally connected application. I am looking for something like SQL Compact Edition.

I have seen various messages on various boards indicating that there either

  • (a) will be no local databases whatsoever
  • (b) no local "server" databases (i.e. SQL Express type instances)
  • (c) A local database code named "Jet Blue".

Does anybody have a definitive answer to this? I do not want to start down this road if it is blocked.

Jeroen Vannevel
  • 43,651
  • 22
  • 107
  • 170
Martin Robins
  • 6,033
  • 10
  • 58
  • 95
  • No local dbase solution is currently available. Kinda silly to guess whether that road is blocked, it is not even in beta yet. – Hans Passant Feb 18 '12 at 17:30
  • Hans; that is a fair comment. I realise that we have not even hit beta, I was just hoping that somebody might have found some more documentation that I had missed. Thanks. – Martin Robins Feb 19 '12 at 13:09
  • 1
    There is a perfectly good local database solution called jet blue... – fabspro Apr 04 '12 at 12:09
  • possible duplicate of [Local storage of structured data in Win8 Metro-style apps](http://stackoverflow.com/questions/7457649/local-storage-of-structured-data-in-win8-metro-style-apps) – Raymond Chen May 30 '12 at 20:59
  • @fabspro - if you would like to submit that as an answer instead of just a comment, I would like to mark it as my accepted answer. it is also worth mentioning the managed wrappers at http://managedesent.codeplex.com/ – Martin Robins Jun 03 '12 at 16:09
  • I think [this](http://www.telerik.com/products/windows-8/controls-xaml/datastorage.aspx) is worthy of a consideration for anyone using a local database in their Windows 8 app, seriously. – Jerry Nixon Aug 13 '13 at 14:58

6 Answers6

6

SQLite is now officially supported. See Tim Heuer's blog for details. For simpler solution with less data you can use http://winrtdatabase.codeplex.com/

Derek Park
  • 45,824
  • 15
  • 58
  • 76
Sergey Barskiy
  • 1,761
  • 2
  • 15
  • 17
4

You might want to have a look at SQLite3-WinRT, a wrapper for SQLite that we wrote to use it in a Metro-style application. It contains a version of SQLite that uses only WinRT-compatible API, and a WinRT component to use it in C# and JavaScript apps.

superquadratic
  • 310
  • 2
  • 4
3

There is no SQL CE available for Metro.

a) will be no local databases whatsoever

This is not true. SQLite should be able to run on WinRT. You can download the code here and include the two main files into your WinRT project. To compile and pass certification you will need to make sure you are using the correct WinRT replacement calls for the Win32 calls that are not supported. The 3rd party solution Bob mentioned is a WinRT wrapper it doesn't include changes to SQLite to pass certification.

(b) no local "server" databases (i.e. SQL Express type instances)

It seems unlikely there will be SQL Express for metro.

(c) A local database code named "Jet Blue".

If you mean Microsoft Jet Database engine, yes that seems to be supported but I would rather use SQLite.

Also remember if you are using HTML/JS you have the option of using IndexedDB

sarvesh
  • 2,743
  • 1
  • 20
  • 30
0

There are 3rd party solutions coming out or are already out. CodePlex has one -- http://sqlwinrt.codeplex.com/

The other option, which requires some work on your part, is to proxy your database access through a web service.

Bob Delavan
  • 647
  • 5
  • 6
  • Thanks for this. I knew that I would have to provide web services for the main database, but since the application will be used in areas where there is no connectivity available (such as under ground) I cannot rely on this for all usage. – Martin Robins Feb 19 '12 at 13:08
  • No problem. I understand the issue around web service and being connected or not. Plus it is work on your part. There are connectivity classes available giving you information about the network (ConnectionProfile.Connected) located under the Windows.Networking.Connectivity namespace. As another user mentioned above, you can rely on INDEXDB as well (http://msdn.microsoft.com/library/hh673548.aspx). – Bob Delavan Feb 19 '12 at 15:39
0

There is no (built in) database according to this
http://channel9.msdn.com/Events/BUILD/BUILD2011/TOOL-930C

Michael Olesen
  • 473
  • 2
  • 9
0

Do you really need a "store data for an occasionally connected application"? This sounds a little overkill to me. Why not serialize the data (various options) to storage yourself?

Jasper
  • 660
  • 1
  • 7
  • 19
  • Jasper: If you take (for example) the scenario of the travelling salesman who is trying to take orders in places where there is no connectivity available then yes, I think a database is a better option - especially when the product list(s) are large and you want to be able to provide searches etc. That said, I accept (to a point) that you could have everything stored in objects and serialise them when the application exits. – Martin Robins Feb 24 '12 at 10:22