On Fri, May 6, 2011 at 7:44 AM, Simon Slavin <slav...@bigfraud.org> wrote:
>
> On 6 May 2011, at 3:43am, Tim Butterfield wrote:
>
>> The blob values are always inserted and read as a byte[].  If those
>> bytes are those of a text file, it fails.  If I add a leading 0x00
>> byte to force it to be binary, it works.
>
> Are you binding your parameters ?  If so, check that you're using 
> sqlite3_bind_blob() when binding something to your BLOB column.  Binding it 
> as text will not trigger an error, since SQLite is quite happy to bind text 
> into a BLOB column.  But if you take blobby data, and bind it using 
> sqlite3_bind_blob() into a column defined as a BLOB SQLite should be 
> retaining and reporting it as as blob, not as text.
>
> If you're creating a fully text 'INSERT' or 'UPDATE' command rather than 
> binding parameters, them make sure you're using the correct format to specify 
> you have blob data (is it \x ?) rather than just supplying text.

I'm using the System.Data.SQLite interface and not the direct C
interface methods.  All of my inserts are done using DbParameter (@p1,
@p2, etc.) and DbCommand insert statements.  The DbParameter.Value is
the C# object type.  In the case of the blob column, that type is a C#
byte[], which sets the parameter type to DbType.Binary whether the
first byte is 0x00 or a more textual value.

Tim
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to