I am using a DbDataReader to return the columns for a SQL  SELECT
statement.  For the blob column, I am calling reader.GetOrdinal to get
the column number, calling reader.GetBytes to get the size of the
data, allocating the byte[], and then calling reader.GetBytes to read
into the buffer.

Tim

On Fri, May 6, 2011 at 11:12 AM, Robert Simpson <[email protected]> wrote:
> How are you fetching the data?  Are you using the generic reader[x] on a
> datareader?  Are you using a DataSet/DataTable?
>
>
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]] On Behalf Of Tim Butterfield
> Sent: Friday, May 06, 2011 8:58 AM
> To: General Discussion of SQLite Database
> Subject: Re: [sqlite] System.Data.SQLite blob column exception
>
> On Fri, May 6, 2011 at 7:44 AM, Simon Slavin <[email protected]> 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
> [email protected]
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
>
> _______________________________________________
> sqlite-users mailing list
> [email protected]
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>



-- 
Tim Butterfield
http://www.timbutterfield.com/
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to