Main Site Documentation

Local database?


I need a local database on my Cobra, and since I found the SQLite in “GHIElectronics.NETMF.SQLite” I figure that it would work. But I get error “System.NotSupportedException” (DB is on my SD card).

I also tested this wrapper but same result.

Is SQLite unsupported in Cobra? If so, any other databases I can use? is LINQ supported? (XML as db maybe).



Database is only supported on ChipworkX as of now

From remark on database class

[quote]ChipworkX supports SQLite database version 3.6.13
This Class exposes simple methods to open, close and process SQL queries.
ChipworkX firmware supports openning multiple database files.
Currently, this version supports INTEGER, DOUBLE and TEXT record types.[/quote]


Thanks for quick replay Gus,

Are there plans for supporting SQLite on Cobra, if so when?

I got the code from that class. My SQLlite DB is 3.5.1 created by



No current plans. Can you get away using files without database?


Well Gus I have to use textiles now, maybe XML. But it’s so mush easier and faster to develop using SQL, since I need search and update insert functions in the DB on Cobra.

I assume that LINQ is not supported on Cobra?



See this


Thats an idea. You could linq to query/update memory objects. Then persist graph as xml or csv, etc.


Is there any plan add sqlite into EMX?
Is there some other replacement?
I need something what will work on EMX(ChipworkX is not option because it don’t have some features) to temporary store data on SD card in 3 “TABLES” one with 0-100 records one with 0-2000 records and one with 0-100000 records. I need:
INSERT - add new record
DELETE - delete record range (example ID>5 AND ID<3000)
SELECT - select one or record range (example ID>5 AND ID<3000) and when select range move to next/previous.

Any sugestion? XML?


Hi Dejan,

I am developing a database I call “CSDB” - the CSV Database for a Fez Domino (now using a Panda).

The “database” is CSV files on an SD card. The rule with the file is that the first column must contain the primary key, and the records must be sorted on this key (by an external program). I then use a binary search to find records by key and return the row as an object graph using JSON de-serialisation. I can only find records based on key - not contents because of speed.

I designed it for fast lookups. It can look up a record with a 12 character key in 250,000 rows in about 50ms direct from the SD card. Not bad for something that uses less than 2k of working memory in the process. I’m very proud :slight_smile:

Anyway, CSDB currently handles updates - with fixed size fields, and inserts - but in a special way. It is too expensive to insert the record into the main file, so I insert new records in a secondary file and then merge them later with a PC program. It can be done directly on the Fez, but I don’t need that at the moment.

I was going to implement a more complete C-ISAM database, with an external index file (real old school stuff), but I just don’t need it for my application at the moment. Maybe with proper community motivation we could build on this.

What is your application?


I just don’t know if I really like this syntax…

  static void Main () {
    var a = new int[] {1, 2, 3, 4, 6, 8, 9, 9, 9};
    var n = a.Where(v => (int) v % 2 == 0).Count();
    var m = (from v in a where (int) v % 2 == 0 select v).Count();
    Debug.Print(n + " " + m);


var m = CountEvenNumbers(a)

more sensible - even with more code work behind it? Sometimes the old fashioned way works (for me anyway)…

Anyway, I’m just being defensive here… I was inspired by the simplicity of SQLite and CSDB does a SELECT like this:

// Attach database
_Csdb = new Csdb(@ "\SD\million items.csv");

// Select a row from the database by the primary key.
result = _Csdb.Pick("12345678");

But my question (to myself) now is how to do a “Select key from db where key > 3000 and key < 5000”. Not so elegant in code as SQL syntax I must admit.


My application constant make some mesaurements and send it to remote server trough custom http API(XML files). When device don’t have access to server(Server down or device GPRS connection is lost) it must save this data to local database(With previous ARM device Im using mono&mysql) and if device lose power this data must be safe stored. When connection/power is back data must be send to server.
Losing few records is not problem. Im also think to Hashtable or some array and save it every time to SD card but I think this is not good way(to many data in RAM and writings to file) :slight_smile:


Writing records to a log file is not a problem - as long as they are sequentially added. It looks like you’re just buffering the data so it should work fine.

Instead of deleting records (I assume you delete when the transmission is successful) you could just change a status indicator on the record and later delete the entire file.

Because memory is so scarce, I’d suggest you store your XML responses on the SD card - and then later stream directly from there without a buffer. Maybe this isn’t such a problem on the EMX, but it certainly is a problem on the small devices like the Panda.

If you’re used to an ARM device with Mono and mySQL then NETMF is going to be hard for you. It is very constrained when it comes to the DB stuff. The benefit is of course cost… You will be able to build your application on an $18 USBIZI chip (it is that powerful), but you will have to program with a different mindset to handle the constraints.