for sql server 2005 (tested)
use batch insert with binding parameters like following:
comm.Parameters.Add("@val", System.Data.SqlDbType.Binary, temp.Length).Value = temp;
comm.ExecuteNonQuery();
don't forget
comm.Parameters.Clear();
otherwise an exception will be raised..
for sqlite with System.Data.Sqlite
comm.Parameters.Clear() is optional...