In C #:
Class Program { Static void main ( String [] ARGs ) { If ( File . Exists ( "Test. db3" )) { File . Delete ( "Test. db3" ); } Using ( VaR connection = New sqliteconnection ( "Data Source = test. db3; version = 3" )) Using ( VaR command = New sqlitecommand ( "Create table photos (ID integer primary key autoincrement, photo BLOB )" , Connection )) { Connection . Open (); Command . Executenonquery (); Byte [] Photo = New byte [] { 1 , 2 , 3 , 4 , 5 }; Command . Commandtext = "Insert into Photos (photo) values (@ photo )" ; Command . Parameters . Add ( "@ Photo" , Dbtype . Binary , 20 ). Value = Photo ; Command . Executenonquery (); Command . Commandtext = "Select photo from photos where id = 1" ; Using ( VaR Reader = Command . Executereader ()) { While ( Reader . Read ()) { Byte [] Buffer = Getbytes ( Reader ); } } } } Static byte [] Getbytes ( Sqlitedatareader Reader ) { Const int chunk_size = 2 * 1024 ; Byte [] Buffer = New byte [ Chunk_size ]; Long bytesread ; Long fieldoffset = 0 ; Using ( Memorystream stream = New memorystream ()) { While (( Bytesread = Reader . Getbytes ( 0 , Fieldoffset , Buffer , 0 , Buffer . Length )) > 0 ) { Stream . Write ( Buffer , 0 , ( Int ) Bytesread ); Fieldoffset + = Bytesread ; } Return Stream . Toarray (); } } }