private void ApplicationControl_Load(object sender, EventArgs e) { #region read var csb = new SQLiteConnectionStringBuilder { DataSource = DataSource, Version = 3 }; using (var c = new SQLiteConnection(csb.ConnectionString)) { c.Open(); { var sql = "create table if not exists Table1 (ContentKey INTEGER PRIMARY KEY AUTOINCREMENT, ContentValue text not null, ContentBytes blob)"; using (var reader = new SQLiteCommand(sql, c).ExecuteReader()) { } } { var sql = "select ContentValue, ContentBytes from Table1"; var cmd = new SQLiteCommand(sql, c); using (var reader = cmd.ExecuteReader()) { while (reader.Read()) { var ContentValue = reader.GetString(reader.GetOrdinal("ContentValue")); var chunkSize = 4096; // Get size of image data–pass null as the byte array parameter long bytesize = reader.GetBytes(reader.GetOrdinal("ContentBytes"), 0, null, 0, 0); // Allocate byte array to hold image data byte[] imageData = new byte[bytesize]; long bytesread = 0; int curpos = 0; while (bytesread < bytesize) { // chunkSize is an arbitrary application defined value bytesread += reader.GetBytes(reader.GetOrdinal("ContentBytes"), curpos, imageData, curpos, chunkSize); curpos += chunkSize; } dataGridView1.Rows.Add( "", ContentValue, "" + bytesize ); } } } } #endregion }