title: Put and retrivel image in SQLite database
body: <p>please help. I read here some topics, but don't get answer on my question. I try put image in BLOB type of SQLite DB and then retrive it, but it failed.</p>
  
  <p>So, using 
  <code>rawDoc = File.ReadAllBytes(openFileDialog.FileName);</code> 
  i get <strong>byte[] rawDoc</strong> of some image (or other file). Then</p>
  
  <pre><code>String dbConnection = "Data Source=dbase.s3db";
  SQLiteConnection cnn = new SQLiteConnection(dbConnection);
  cnn.Open();
  String sql = String.Format("INSERT INTO registry" +
              "(NameDoc, YearDoc, MonthDoc, DayDoc, RawDoc) VALUES" +
              "('{0}', '{1}', '{2}', '{3}', '{4}')",
              txtNameDoc.Text, numUDYear.Value, numUDD.Value, numUDD.Value, Convert.ToBase64String(rawDoc));
  </code></pre>
  
  <p>if i try verify <strong>rawDoc</strong> with that</p>
  
  <pre><code>byte[] imageBytes = Convert.FromBase64String(testRaw);
          MemoryStream ms = new MemoryStream(imageBytes, 0, imageBytes.Length);
          ms.Write(imageBytes, 0, imageBytes.Length);
          pictureBox1.Image = Image.FromStream(ms, true);
  </code></pre>
  
  <p>I get normal picture. But if i try do that with data from SQLite base with</p>
  
  <pre><code>SQLiteCommand myCommand = new SQLiteCommand(query, cnn);
          SQLiteDataReader myDataReader = myCommand.ExecuteReader();
  
          string raw = null;
          while (myDataReader.Read())
          {
             raw += myDataReader["RawDoc"].ToString().Trim();
  
          }
  
          myDataReader.Close();
  byte[] imageBytes = Convert.FromBase64String(raw);
          MemoryStream ms = new MemoryStream(imageBytes, 0, imageBytes.Length);
          ms.Write(imageBytes, 0, imageBytes.Length);
  
          imageBox imgbox = new imageBox();
          PictureBox picBox = new PictureBox();
          picBox.Image = Image.FromStream(ms, true);
          imgbox.Controls.Add(picBox);
          imgbox.Show();
  </code></pre>
  
  <p>I get an error: FormatException. Invalid characters in a string Base-64. Why?</p>
  
  <p>thanks a lot!</p>