C S <[EMAIL PROTECTED]> wrote:
> hi all i have a question regarding Blobs, that is
> storing images into the database.
>
> my image by default is an unsigned short array and to
> bind blobs it wants a byte array. i am not sure i am
> doing this right at all. is there a universal cross
> platform way for this easy conversion?

unsigned short* image;
char* blob = reinterpret_cast<char*>(image);

> so far the code i have is:
> .........
> char *byteArray = (char *) malloc((size * 2) *
> sizeof(char));

Curious that you bothered to write sizeof(char), which is always 1 by 
definition, but just hardcoded 2 instead of sizeof(unsigned short).

Anyway, you don't need to allocate new memory or do any copying.

> then i prepare the statement which is successful then:
>
> status = sqlite3_bind_blob(statement, 1, byteArray,
> size * 2, free);
>
> some questions i have: i get an error of '25' back
> from status and looking on the sqlite documention it
> says the 2nd parameter to sql bind was out of range. i
> have no idea how the 2nd parameter can be out of
> range.

You don't have any parameter placeholders in your statement. Show your 
sqlite3_prepare call, in particular what SQL you pass to it.

> my next question is once you have the blob in the
> database how in the world do you read it back out?

sqlite3_column_blob

Igor Tandetnik 



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

Reply via email to