0

I followed some tutorial on YouTube and found how to install "SQLite for Universal Windows Platform", and I had to make one class with this in it:

[PrimaryKey,AutoIncrement]
public int ID { get; set; }
public string Content { get; set; }

It is for saving of a text. And in my MainPage.xaml.cs I made connection with this database like following

path = System.IO.Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "db.sqlite");
conn = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(),path);
conn.CreateTable<Message>();

And then I added some text to it (when I click the button)

var add = conn.Insert(new Message() { Content = textBox.Text});

This all works fine, but how can I store image (which user will upload from their phone or Desktop) to this Database?

Sergii Zhevzhyk
  • 4,074
  • 22
  • 28
arma_best
  • 65
  • 1
  • 2
  • 13
  • 1
    Have you checked this answer [Save and Load image SQLite C#](http://stackoverflow.com/questions/10853301/save-and-load-image-sqlite-c-sharp)? – Sergii Zhevzhyk Dec 10 '15 at 14:58
  • This will maybe work but still I don't know how to save image to database ... @SergiiZhevzhyk – arma_best Dec 10 '15 at 15:44
  • Probably, you should add more information and code concerning this problem. Show us what kind of images do you want to save. – Sergii Zhevzhyk Dec 10 '15 at 15:45
  • I used FileOpenPicker to open let user select picture from phone or Desktop... After that I did this `var stream = await file.OpenAsync(Windows.Storage.FileAccessMode.Read); var image = new BitmapImage(); image.SetSource(stream); imageXaml.Source = image;` And this just added selected image to `` – arma_best Dec 10 '15 at 16:01
  • 1
    was asked recently here too http://stackoverflow.com/questions/34146359/uwp-app-add-an-image-path-to-sqlite-database/34150130#34150130 look at that maybe it will guide you more – Depechie Dec 10 '15 at 17:45

0 Answers0