Store blob in sqlite database RRS feed

  • General discussion

  • Hey

    I want to save an object as a blob in a sqllite database. To serialize an object I found the DataContractSerializer and the XMLSerializer ...

    Is it possible to create a blob in a windows store app an save it in the sqlite database? Would be great if you could give me an example....
    Thursday, June 13, 2013 12:24 PM

All replies

  • Hi flutter-by

    I found something you may interested, ref here: https://github.com/doo/SQLite3-WinRT

    it contains the example for C++ and Javascript, I hope this will help you.

    anyway, I will change this thread as discussion, because this is a sqlite question, hope you can understand.

    Good luck.

    James He
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, June 19, 2013 7:24 AM
  • Hi ,

    Let's say that you have opened your tables in Sqlite from a class

        public class tbTest
                [PrimaryKey, AutoIncrement]
                public Int32 Auto_Sequence { get; set; }
                public byte[] CompanyLogo { get; set; }

    Pay attention in the byte declaration. This is your "Blob".  Now let's save it in the local database  

      var db = MyConnection();

    where MyConnection is the connect that you are doing with your database.

       private SQLite.SQLiteConnection MyConnection()
                    var db = new SQLite.SQLiteConnection(app.dbpath); //you already know the path of the database I'm just keeping it in a global variable.
                    return db;  


                        db.RunInTransaction(() =>

                               db.Insert(new Myapplication.App.tbTest()
                                         CompanyLogo = MyByteArray variable


    You don't care about the autincrement field because the database will assign a PK.   Hope this gave you a head start

    Wednesday, June 19, 2013 12:06 PM